![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Mircroprocessor revised code 9/22
Fork of m3pi_HelloWorld by
Diff: main.cpp
- Revision:
- 8:abc27ba9f8f3
- Parent:
- 7:d0689e8f23bf
- Child:
- 9:b723c1cdaae4
diff -r d0689e8f23bf -r abc27ba9f8f3 main.cpp --- a/main.cpp Fri May 13 10:51:57 2011 +0000 +++ b/main.cpp Thu Sep 18 18:55:58 2014 +0000 @@ -1,23 +1,30 @@ -#include "mbed.h" -#include "m3pi.h" - -m3pi m3pi; - -int main() { - - m3pi.locate(0,1); - m3pi.printf("LO World"); - - wait (2.0); - - 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 - - m3pi.stop(); -} \ No newline at end of file + #include "mbed.h" + #include "m3pi.h" + + m3pi m3pi; + + Timer stopwatch; + DigitalOut myled(LED1); + + int main(){ + + int oldtime=0; + + m3pi.stop(); + + m3pi.locate(0,1); + m3pi.printf("butts"); + + stopwatch.reset(); + stopwatch.start(); + + while (1) { + m3pi.locate(0,0); + m3pi.printf("%i",stopwatch.read_ms()); + if (stopwatch,read_ms()-oldtime>1000) { + myled=!myled; + oldtime=stopwatch.read_ms(); + + } + } + } \ No newline at end of file