MicroMouse

Dependencies:   QEI mbed

Revision:
0:524c6a42541a
Child:
1:92eb1c9934ee
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 22 23:50:09 2015 +0000
@@ -0,0 +1,86 @@
+#include "mbed.h"
+#include "PinDefinitions.h"
+
+Serial pc(USBTX, USBRX);
+InterruptIn mybutton(USER_BUTTON);
+DigitalOut LD3(LD3);
+DigitalOut motor_enabler(PB_6);
+
+int distance = LENC.getPulses();
+
+
+void setLeftPwm(float speed) {
+    if (speed == 0) {
+        LMOTORA = 1.0;
+        LMOTORB = 1.0;
+    }
+    
+    if (speed > 0) {
+        LMOTORA = speed;
+        LMOTORB = 0;
+    }
+    else {
+        LMOTORA = 0;
+        LMOTORB = -speed;
+    }
+}
+
+void setRightPwm(float speed) {
+    if (speed == 0) {
+        RMOTORA = 1.0;
+        RMOTORB = 1.0;
+    }
+    
+    if (speed > 0) {
+        RMOTORA = speed;
+        RMOTORB = 0;
+    }
+    else {
+        RMOTORA = 0;
+        RMOTORB = -speed;
+    }
+}
+
+void pressed()
+{
+    //led1 = !led1;
+    pc.printf("Hellooooo\r\n");
+}
+
+int main() {
+
+    //mybutton.fall(&pressed);
+    LD3 = 0;
+    
+    motor_enabler = 1;
+    while(1){
+        
+        RMOTORA = 1.0;
+        RMOTORB = 0;
+        LMOTORA = 1.0;
+        LMOTORB = 0;
+        
+    }
+    
+}    
+        /*
+        while (LENC.getPulses() < 5000) {
+            led1 = 1;
+            setLeftPwm(0.5);
+        }
+        LENC.reset();
+        while (LENC.getPulses() < 5000) {
+            led1 = 0;
+            setLeftPwm(0.25);
+        }
+        LENC.reset();
+        while (LENC.getPulses() < 10000) {
+            led1 = 1;
+            setLeftPwm(1.0);
+       }
+       */
+       
+       
+       
+    
+