An m3pi demo program for Bluetooth control.
Dependencies: X_NUCLEO_53L0A1 m3pi mbed
Fork of m3pi_LIDAR by
Revision 3:d5da5e6bc16f, committed 2017-05-01
- Comitter:
- alexsaadfalcon
- Date:
- Mon May 01 02:11:02 2017 +0000
- Parent:
- 2:2d0d003ca3b8
- Commit message:
- Fully functional
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2d0d003ca3b8 -r d5da5e6bc16f main.cpp --- a/main.cpp Sun Apr 30 23:08:34 2017 +0000 +++ b/main.cpp Mon May 01 02:11:02 2017 +0000 @@ -3,33 +3,43 @@ m3pi m3pi; DigitalOut led(LED1); +DigitalOut pong(p20); Serial bt(p13, p14); //TX, RX -int main() { - m3pi.locate(0,5); +int main() +{ + m3pi.locate(0,1); m3pi.printf("YO"); - + bt.baud(9600); //make sure the baud rate is 9600 while (!bt.readable()) { } //wait until the bt is ready while(1) { - if (bt.getc()=='F') { - m3pi.forward(.25); - } - if (bt.getc()=='B') { - m3pi.backward(.25); - } - if (bt.getc()=='L') { - m3pi.left(.25); + led = !led; + if (bt.getc() == '!') { + if (bt.getc() == 'O') { + if (bt.getc()=='F') { + m3pi.forward(.25); + } + if (bt.getc()=='B') { + m3pi.backward(.25); + } + if (bt.getc()=='L') { + m3pi.left(.25); + } + if (bt.getc()=='R') { + m3pi.right(.25); + } + if (bt.getc()=='S') { + m3pi.stop(); + } + if (bt.getc()=='X') { + pong = 1; + wait(.001); + pong = 0; + } + } } - if (bt.getc()=='R') { - m3pi.right(.25); - } - if (bt.getc()=='S') { - m3pi.stop(); - } - if (bt.getc()=='X') { - //launch - } + while (bt.readable()) char temp = bt.getc(); //flush buffer } } \ No newline at end of file