MicroMouse

Dependencies:   QEI mbed

Files at this revision

API Documentation at this revision

Comitter:
nathanielchu
Date:
Sat Oct 24 17:39:58 2015 +0000
Parent:
0:524c6a42541a
Commit message:
commit 2 - testing encoders

Changed in this revision

PinDefinitions.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 524c6a42541a -r 92eb1c9934ee PinDefinitions.h
--- a/PinDefinitions.h	Thu Oct 22 23:50:09 2015 +0000
+++ b/PinDefinitions.h	Sat Oct 24 17:39:58 2015 +0000
@@ -1,8 +1,8 @@
 #include "mbed.h"
 #include "QEI.h"
 
-PwmOut LMOTORA(PB_5);
+PwmOut LMOTORA(PB_5);   // change these to D
 PwmOut LMOTORB(PB_10); 
 PwmOut RMOTORA(PA_6); 
 PwmOut RMOTORB(PB_8); 
-QEI LENC (PC_1, PC_0, NC, 100);
\ No newline at end of file
+QEI LENC (PC_1, PC_0, NC, 100);     // are the encoder pins correct?
\ No newline at end of file
diff -r 524c6a42541a -r 92eb1c9934ee main.cpp
--- a/main.cpp	Thu Oct 22 23:50:09 2015 +0000
+++ b/main.cpp	Sat Oct 24 17:39:58 2015 +0000
@@ -1,10 +1,10 @@
 #include "mbed.h"
 #include "PinDefinitions.h"
 
-Serial pc(USBTX, USBRX);
+Serial pc(USBTX, USBRX);        // serial pc not working yet
 InterruptIn mybutton(USER_BUTTON);
-DigitalOut LD3(LD3);
-DigitalOut motor_enabler(PB_6);
+DigitalOut Led3(LD3);
+DigitalOut motor_enabler(PB_6);     //change this to D
 
 int distance = LENC.getPulses();
 
@@ -43,44 +43,39 @@
 
 void pressed()
 {
-    //led1 = !led1;
+    Led3 = !Led3;
     pc.printf("Hellooooo\r\n");
 }
 
 int main() {
 
-    //mybutton.fall(&pressed);
-    LD3 = 0;
+    mybutton.fall(&pressed);
+    Led3 = 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);
-       }
-       */
+    while (LENC.getPulses() < 5000) {   //while encoder pulses are less than 5000, turn led3 on and set LMOTORA to 0.50
+        led3 = 1;
+        setLeftPwm(0.5);
+    }
+    LENC.reset();                       // reset encoder pulse count to zero
+    while (LENC.getPulses() < 5000) {   //while encoder pulses are less than 5000, turn led3 off and set LMOTORA to 0.25
+        led3 = 0;
+        setLeftPwm(0.25);
+    }
+    LENC.reset();
+    while (LENC.getPulses() < 10000) {  //while encoder pulses are less than 10000, turn led3 on and set LMOTORA to 1.00
+        led3 = 1;
+        setLeftPwm(1.0);
+    }
+
+    
+  
+        
+ 
        
        
+}