![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Bletooth
Dependencies: mbed
main.cpp@0:1f7823a82513, 2017-02-09 (annotated)
- Committer:
- DonatoSt
- Date:
- Thu Feb 09 14:36:24 2017 +0000
- Revision:
- 0:1f7823a82513
Bluetooth
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DonatoSt | 0:1f7823a82513 | 1 | #include "mbed.h" |
DonatoSt | 0:1f7823a82513 | 2 | Serial bt(D10,D2); //RX TX |
DonatoSt | 0:1f7823a82513 | 3 | Serial pc(USBTX, USBRX); |
DonatoSt | 0:1f7823a82513 | 4 | DigitalOut dcm01(D6); |
DonatoSt | 0:1f7823a82513 | 5 | DigitalOut dcm02(D7); |
DonatoSt | 0:1f7823a82513 | 6 | DigitalOut dcm03(D4); |
DonatoSt | 0:1f7823a82513 | 7 | DigitalOut dcm04(D5); |
DonatoSt | 0:1f7823a82513 | 8 | char x; |
DonatoSt | 0:1f7823a82513 | 9 | |
DonatoSt | 0:1f7823a82513 | 10 | |
DonatoSt | 0:1f7823a82513 | 11 | |
DonatoSt | 0:1f7823a82513 | 12 | |
DonatoSt | 0:1f7823a82513 | 13 | int main() |
DonatoSt | 0:1f7823a82513 | 14 | { |
DonatoSt | 0:1f7823a82513 | 15 | |
DonatoSt | 0:1f7823a82513 | 16 | bt.baud(9600); |
DonatoSt | 0:1f7823a82513 | 17 | |
DonatoSt | 0:1f7823a82513 | 18 | while(1) { |
DonatoSt | 0:1f7823a82513 | 19 | if (bt.readable()) { |
DonatoSt | 0:1f7823a82513 | 20 | x= bt.putc(bt.getc()); |
DonatoSt | 0:1f7823a82513 | 21 | |
DonatoSt | 0:1f7823a82513 | 22 | |
DonatoSt | 0:1f7823a82513 | 23 | if ( x == 'a') { |
DonatoSt | 0:1f7823a82513 | 24 | |
DonatoSt | 0:1f7823a82513 | 25 | dcm01 = 1; |
DonatoSt | 0:1f7823a82513 | 26 | dcm02 = 0; |
DonatoSt | 0:1f7823a82513 | 27 | dcm03 = 1; |
DonatoSt | 0:1f7823a82513 | 28 | dcm04 = 0; |
DonatoSt | 0:1f7823a82513 | 29 | |
DonatoSt | 0:1f7823a82513 | 30 | } |
DonatoSt | 0:1f7823a82513 | 31 | |
DonatoSt | 0:1f7823a82513 | 32 | if (x == 'b') { |
DonatoSt | 0:1f7823a82513 | 33 | |
DonatoSt | 0:1f7823a82513 | 34 | dcm01 = 0; |
DonatoSt | 0:1f7823a82513 | 35 | dcm02 = 1; |
DonatoSt | 0:1f7823a82513 | 36 | dcm03 = 0; |
DonatoSt | 0:1f7823a82513 | 37 | dcm04 = 1; |
DonatoSt | 0:1f7823a82513 | 38 | |
DonatoSt | 0:1f7823a82513 | 39 | } |
DonatoSt | 0:1f7823a82513 | 40 | |
DonatoSt | 0:1f7823a82513 | 41 | if (x== 'c') { |
DonatoSt | 0:1f7823a82513 | 42 | |
DonatoSt | 0:1f7823a82513 | 43 | dcm01 = 1; |
DonatoSt | 0:1f7823a82513 | 44 | dcm02 = 0; |
DonatoSt | 0:1f7823a82513 | 45 | dcm03 = 0; |
DonatoSt | 0:1f7823a82513 | 46 | dcm04 = 1; |
DonatoSt | 0:1f7823a82513 | 47 | } |
DonatoSt | 0:1f7823a82513 | 48 | if (x== 'd') { |
DonatoSt | 0:1f7823a82513 | 49 | |
DonatoSt | 0:1f7823a82513 | 50 | dcm01 = 0; |
DonatoSt | 0:1f7823a82513 | 51 | dcm02 = 1; |
DonatoSt | 0:1f7823a82513 | 52 | dcm03 = 1; |
DonatoSt | 0:1f7823a82513 | 53 | dcm04 = 0; |
DonatoSt | 0:1f7823a82513 | 54 | } |
DonatoSt | 0:1f7823a82513 | 55 | if (x== 'e') { |
DonatoSt | 0:1f7823a82513 | 56 | |
DonatoSt | 0:1f7823a82513 | 57 | dcm01 = 0; |
DonatoSt | 0:1f7823a82513 | 58 | dcm02 = 0; |
DonatoSt | 0:1f7823a82513 | 59 | dcm03 = 0; |
DonatoSt | 0:1f7823a82513 | 60 | dcm04 = 0; |
DonatoSt | 0:1f7823a82513 | 61 | } |
DonatoSt | 0:1f7823a82513 | 62 | |
DonatoSt | 0:1f7823a82513 | 63 | |
DonatoSt | 0:1f7823a82513 | 64 | }//chiusa if (bt.readable()) |
DonatoSt | 0:1f7823a82513 | 65 | |
DonatoSt | 0:1f7823a82513 | 66 | }//Chiusa while |
DonatoSt | 0:1f7823a82513 | 67 | }//Chiusa main |
DonatoSt | 0:1f7823a82513 | 68 |