Ling Ye
/
Serial
bbb
main.cpp
- Committer:
- lingye96
- Date:
- 2016-11-01
- Revision:
- 0:48d48099e20c
- Child:
- 1:a95f56d5e053
File content as of revision 0:48d48099e20c:
#include "mbed.h" #include "m3pi.h" m3pi m3pi; Serial pc(USBTX,USCRX); int main() { m3pi.locate(0,1); m3pi.printf("Serial Control"); pc.printf("Press 'WASD' to control the m3pi\n"); while (1) { wait (2.0); char input = pc.getc(); if(input=='w') { m3pi.forward(0.5); // Forward half speed wait (0.5); // wait half a second } else if (input=='a') { m3pi.left(0.5); // Turn left at half speed wait (0.5); // wait half a second } else if (input=='s') } m3pi.backward(0.5);// Backward at half speed wait (0.5); // wait half a second } else if (input=='d') { m3pi.right(0.5); // Turn right at half speed wait (0.5); // wait half a second } else { pc.printf("Try again and press 'WASD' to control the m3pi\n"); } m3pi.printf("Complete"); } }