Hello world program that just gets the m3pi moving
Fork of m3pi_HelloWorld by
Revision 8:c9f5f6464497, committed 2018-03-06
- Comitter:
- jograesser
- Date:
- Tue Mar 06 17:07:54 2018 +0000
- Parent:
- 7:d0689e8f23bf
- Commit message:
- final;
Changed in this revision
--- a/m3pi.lib Fri May 13 10:51:57 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/chris/code/m3pi/#4b7d6ea9b35b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m3pi_ng.lib Tue Mar 06 17:07:54 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/ngoldin/code/m3pi_ng/#5589eef1f879
--- 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