Nathaniel Chu
/
MicroMouse
MicroMouse
Diff: main.cpp
- Revision:
- 1:92eb1c9934ee
- Parent:
- 0:524c6a42541a
--- 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); + } + + + + + +}