Test code for motors, sensors and leds

Dependencies:   PRRobot mbed

Revision:
0:e0510fa64cef
Child:
1:17d31177e3c0
diff -r 000000000000 -r e0510fa64cef main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 26 17:29:53 2016 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "robot.h"
+
+DigitalOut myled(LED1);
+Robot robot;
+
+
+int main() {
+    pc.baud(115200);
+    pc.printf("PR Robot\n");
+    robot.init();
+    motors.init();
+    led.start_test();
+    
+    while(1){
+    for(int i=1;i<100;i++){
+        pc.printf("Speed: %1.2f [I=%2.4f] \n",0.01*i,motors.get_current_left());
+        motors.set_left_motor_speed(0.01 * i);  
+        wait(0.5); 
+    }
+    motors.brake();
+    wait(0.5);
+    for(int i=1;i<100;i++){
+        pc.printf("Speed: -%1.2f [I=%2.4f] \n",0.01*i,motors.get_current_left());
+        motors.set_left_motor_speed(-0.01 * i);  
+        wait(0.5); 
+    }
+    motors.coast();
+    wait(0.5);
+    }
+    while(1) {
+        myled = 1;
+        /*
+        for(int i=0;i<8;i++){
+          pc.printf("Sensor %d: %d\n",i,sensors.read_adc_value(i));
+          wait(0.05);   
+        }
+        */
+        
+        pc.printf("Sensor 2: %d\n",sensors.get_adc_value(2));
+        wait(0.1);
+        myled = 0;
+        wait(0.1);
+       // pc.printf("V: %3.3f\n",robot.get_battery_voltage());
+    }
+}