mariangela mone
/
BLUETOOTH
bluetooth
Diff: main.cpp
- Revision:
- 1:d33dca22f3a1
- Parent:
- 0:1cd78549370a
--- a/main.cpp Fri Oct 06 14:39:40 2017 +0000 +++ b/main.cpp Fri Nov 16 11:37:29 2018 +0000 @@ -1,13 +1,24 @@ #include "mbed.h" #include "SoftSerial.h" -PwmOut mypwm(D5); +PwmOut mypwm(D6); + +PwmOut mypwm1(D5); + +PwmOut mypwm2(D9); + +PwmOut mypwm3(D10); Serial pc(USBTX,USBRX); DigitalOut myled(LED1); -SoftSerial bt(D2,D3); +DigitalOut aa(D5); +DigitalOut ab(D6); +DigitalOut ba(D9); +DigitalOut bb(D10); +SoftSerial bt(D2,D3); //TX RX char receive; float vel; + int main() { while(1) @@ -15,10 +26,60 @@ if (bt.readable()>0) { receive=bt.getc(); + //invio=bt.putc(); + //if(receive=='1')myled=!myled; //toggle vel=receive-48; vel/=10; pc.printf("%c %f\n\r", receive, vel); + if(receive=='1'){ + bt.printf("ciao"); + aa=0; + ab=1; + ba=0; + bb=1; + } + if(receive=='2'){ + aa=1; + ab=0; + ba=1; + bb=0; + } + if(receive=='0'){ + aa=0; + ab=0; + ba=0; + bb=0; + } + if(receive=='3'){ + + aa=0; + ab=0; + ba=0; + bb=1; + } + if(receive=='4'){ + + aa=0; + ab=0; + ba=1; + bb=0; + } + if(receive=='5'){ + + aa=0; + ab=1; + ba=0; + bb=0; + } + if(receive=='6'){ + + aa=1; + ab=0; + ba=0; + bb=0; + } + } - mypwm.write(vel); + mypwm.write(LED1); } }