part1 in progress

Dependencies:   Motordriver Servo mbed

Revision:
0:306c3cd7fc05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 24 02:38:53 2015 +0000
@@ -0,0 +1,56 @@
+// test code, this demonstrates working motor drivers. 
+// full reverse to full stop, dynamicaly brake and switch off.
+#include "mbed.h"
+#include "motordriver.h"
+#include "Servo.h"
+DigitalOut myled(LED1);
+//PwmOut servo1(p23);
+Motor A(p22, p11, p12, 1); // pwm, fwd, rev, can brake 
+//Motor B(p21, p7, p8, 1); // pwm, fwd, rev, can brake
+Servo s1(p23);
+
+int main() {
+    //PWMout1.period(1.0/50.0);
+    int i = 0;
+    bool up = true;
+    s1.calibrate(0.02, 180); //myServo.calibrate(x,y)
+                              //x sets servo rotate speed
+                              //y sets full range of rotation
+                              //in reality, even though we set range to 180deg, the actual range
+                              //the servo reaches is slightly less than 180deg
+    while(1) {
+          s1 = i/100.0;
+          wait(0.01);
+          //Sensor moves from one extreme position to the other
+          if (up) {
+            i++;
+            if (i == 100) {up = false;}
+          }
+          //Sensor moves from one extreme position to the other
+          else {
+            i--;
+            if (i == 0) {up = true;}
+          }
+        A.speed(-0.8);
+        wait(0.01);
+    }
+        
+/*
+while (1) {
+    
+    //for (float s= -1.0; s < 0.0 ; s += 0.01) {
+        //A.speed(s);
+        //B.speed(s);
+        //wait(0.02);
+    //}
+    
+    while (1) {
+        A.speed(-0.8);
+        wait(0.01);
+    }
+    A.stop(0.5);
+    wait(1);
+    A.coast();
+}
+*/
+}