This is a check program for the Robocon Magazine.

Dependencies:   mbed

Revision:
0:8123026ac7a4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jan 16 16:02:29 2013 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+
+PwmOut motor1(p26);
+PwmOut motor2(p25);
+PwmOut motor3(p24);
+PwmOut motor4(p23);
+DigitalOut myled(LED1);
+
+#define PERIOD 0.00005
+
+int motor(int right, int left)
+{
+    if (right > 0) {
+        motor1.pulsewidth(0.0);
+        motor2.pulsewidth(PERIOD *    right  / 200);
+    } else {
+        motor1.pulsewidth(PERIOD * (- right) / 200);
+        motor2.pulsewidth(0.0);
+    }
+    if (left > 0) {
+        motor4.pulsewidth(0.0);
+        motor3.pulsewidth(PERIOD *    left / 200);
+    } else {
+        motor4.pulsewidth(PERIOD * (- left) / 200);
+        motor3.pulsewidth(0.0);
+    }
+    return 0;
+}
+
+
+int main() {
+    motor1.period(PERIOD);
+    motor1.pulsewidth(0.0);
+    motor2.period(PERIOD);
+    motor2.pulsewidth(0.0);
+    motor3.period(PERIOD);
+    motor3.pulsewidth(0.0);
+    motor4.period(PERIOD);
+    motor4.pulsewidth(0.0);
+    int right = 0, left = 0, del = 10;
+    while(1){
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+        right += del;
+        left  += del;
+        if ((right >= 100)||(right <= -100)) del *= -1;
+        motor(right, left);
+    }
+}
+