bbb

Dependencies:   m3pi mbed

Fork of Serial by Ling Ye

main.cpp

Committer:
lingye96
Date:
2016-11-02
Revision:
1:a95f56d5e053
Parent:
0:48d48099e20c

File content as of revision 1:a95f56d5e053:

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

m3pi m3pi;
Serial pc(USBTX, USBRX); 

int main() {

    m3pi.locate(0,1);
    pc.printf("Press and control the m3pi\n");
    while(1)
    {
        char c = pc.getc();
        if(c =='w')
        {
            m3pi.forward(0.5); // Forward half speed
            wait (0.25);        // wait half a second
            m3pi.stop();
        } 
        if (c =='a')
        {
            m3pi.left(0.5);    // Turn left at half speed
            wait (0.25);        // wait half a second
            m3pi.stop();
        }   
        if (c =='s')
        {
            m3pi.backward(0.5);    // Turn left at half speed
            wait (0.25);        // wait half a second
            m3pi.stop();
        }   
        if (c =='d')
        {
            m3pi.right(0.5);    // Turn left at half speed
            wait (0.25);        // wait half a second
            m3pi.stop();
        }   
        wait (2.0);
        
    }
}