mariangela mone
/
BLUETOOTH
bluetooth
main.cpp@0:1cd78549370a, 2017-10-06 (annotated)
- Committer:
- YARodriguez
- Date:
- Fri Oct 06 14:39:40 2017 +0000
- Revision:
- 0:1cd78549370a
- Child:
- 1:d33dca22f3a1
Manejo de bluetooth con un motor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
YARodriguez | 0:1cd78549370a | 1 | #include "mbed.h" |
YARodriguez | 0:1cd78549370a | 2 | #include "SoftSerial.h" |
YARodriguez | 0:1cd78549370a | 3 | |
YARodriguez | 0:1cd78549370a | 4 | PwmOut mypwm(D5); |
YARodriguez | 0:1cd78549370a | 5 | Serial pc(USBTX,USBRX); |
YARodriguez | 0:1cd78549370a | 6 | DigitalOut myled(LED1); |
YARodriguez | 0:1cd78549370a | 7 | SoftSerial bt(D2,D3); |
YARodriguez | 0:1cd78549370a | 8 | |
YARodriguez | 0:1cd78549370a | 9 | char receive; |
YARodriguez | 0:1cd78549370a | 10 | float vel; |
YARodriguez | 0:1cd78549370a | 11 | int main() |
YARodriguez | 0:1cd78549370a | 12 | { |
YARodriguez | 0:1cd78549370a | 13 | while(1) |
YARodriguez | 0:1cd78549370a | 14 | { |
YARodriguez | 0:1cd78549370a | 15 | if (bt.readable()>0) |
YARodriguez | 0:1cd78549370a | 16 | { |
YARodriguez | 0:1cd78549370a | 17 | receive=bt.getc(); |
YARodriguez | 0:1cd78549370a | 18 | vel=receive-48; |
YARodriguez | 0:1cd78549370a | 19 | vel/=10; |
YARodriguez | 0:1cd78549370a | 20 | pc.printf("%c %f\n\r", receive, vel); |
YARodriguez | 0:1cd78549370a | 21 | } |
YARodriguez | 0:1cd78549370a | 22 | mypwm.write(vel); |
YARodriguez | 0:1cd78549370a | 23 | } |
YARodriguez | 0:1cd78549370a | 24 | } |