![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Hello world program that just gets the m3pi moving
Fork of m3pi_HelloWorld by
Diff: main.cpp
- Revision:
- 8:c9f5f6464497
- Parent:
- 7:d0689e8f23bf
--- a/main.cpp Fri May 13 10:51:57 2011 +0000 +++ b/main.cpp Tue Mar 06 17:07:54 2018 +0000 @@ -1,23 +1,79 @@ #include "mbed.h" -#include "m3pi.h" +#include "m3pi_ng.h" +#include <string> + m3pi m3pi; +Serial Ser(USBTX, USBRX); // tx, rx +char ser_data[20]; +DigitalIn button(p21); +int raw_data[5]; +BusOut led(p19); +BusOut led2(p20,p19,p18,p17,p16,p15,p14,p13); int main() { - + m3pi.reset(); + led2 = 0; + m3pi.locate(0,1); - m3pi.printf("LO World"); - - wait (2.0); + float bat_vol = m3pi.battery(); + m3pi.printf("%d",bat_vol); + + char doh[] ="V1504E4C8D8E8C8D8E8F4D8E8F8D8E8F8GG8E8D8C4"; + m3pi.playtune(doh,40); + + + for( int i=0; i<5;i++){ + + m3pi.raw_sensor(raw_data); + for(int u=0;u<5;u++){ + + + Ser.printf("%d",raw_data[u]); + Ser.printf("\r\n"); + } + wait(1); + Ser.printf("\n"); + } + + + + /* + //blinkenlights + while(button){ + + led= 255; + wait(1); + led =0 ; + wait(1); + } + */ + + + + /* + + Ser.scanf(ser_data); + m3pi.printf(ser_data); - m3pi.forward(0.5); // Forward half speed - wait (0.5); // wait half a second - m3pi.left(0.5); // Turn left at half speed - wait (0.5); // wait half a second - m3pi.backward(0.5);// Backward at half speed - wait (0.5); // wait half a second - m3pi.right(0.5); // Turn right at half speed - wait (0.5); // wait half a second + while(button){ + m3pi.printf("P21"); + wait(1); + m3pi.cls(); + } + + */ + /* + + m3pi.forward(0.25); // Forward half speed + wait (1); // wait half a second + m3pi.left(0.25); // Turn left at half speed + wait (1); // wait half a second + m3pi.backward(0.25);// Backward at half speed + wait (1); // wait half a second + m3pi.right(0.25); // Turn right at half speed + wait (1); // wait half a second + */ m3pi.stop(); } \ No newline at end of file