An m3pi demo program for Bluetooth control.

Dependencies:   X_NUCLEO_53L0A1 m3pi mbed

Fork of m3pi_LIDAR by Alexander Saad-Falcon

main.cpp

Committer:
alexsaadfalcon
Date:
2017-04-30
Revision:
2:2d0d003ca3b8
Parent:
0:b7ef99889b44
Child:
3:d5da5e6bc16f

File content as of revision 2:2d0d003ca3b8:

#include "mbed.h"
#include "m3pi.h"

m3pi m3pi;
DigitalOut led(LED1);
Serial bt(p13, p14); //TX, RX

int main() {
    m3pi.locate(0,5);
    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);
        }
        if (bt.getc()=='R') {
            m3pi.right(.25);
        }
        if (bt.getc()=='S') {
            m3pi.stop();
        }
        if (bt.getc()=='X') {
            //launch
        }
    }
}