You are viewing an older revision! See the latest version
m3pi RobotRacing
Robot racing was the very first activity we tried with the m3pi robot. The challenge was to drive around the track as fast as possible either by scripting the m3pi with some hard-coded movements, or writing a line follower.
This page pulls together the resources we've pulled together.
Lap timer¶
The lap timer was a novel idea using Javascript running in a web browser to catch the pipe characters "|" which started and stopped the timer.

The stand alone HTML file that implements the timer canbe downloaded here :
The actual measurement is done using a optical beam across the track that triggers the start/stop action when the robot breaks the beam.
Beam breaker¶
The next part of this novel timer was to use an mbed as a USB keyboard, so it can then "type" the pipe characters to the web browser. The mbed also has a beam breaker connected to it which is used to trigger the typing!
 
Import program
00001 #include "mbed.h" 00002 #include "USBKeyboard.h" 00003 00004 DigitalOut trigger(LED1); 00005 DigitalIn event(p22); 00006 USBKeyboard k; 00007 00008 int main() { 00009 while (1) { 00010 trigger = event; 00011 if (event) { 00012 k.putc('|'); 00013 trigger = event; 00014 wait(1); 00015 while (!event) { 00016 trigger = event; 00017 } 00018 } 00019 } 00020 }