code for basic movement of robot
Dependencies: MODSERIAL QEI mbed
Diff: main.cpp
- Revision:
- 2:27fe9488ba61
- Parent:
- 0:e2de1fe5b34c
- Child:
- 3:b913f8ea69e8
--- a/main.cpp Mon Oct 05 21:00:15 2015 +0000 +++ b/main.cpp Wed Oct 07 17:22:29 2015 +0000 @@ -8,10 +8,12 @@ DigitalOut direction1(D7); PwmOut speed1(D6); DigitalIn button1(PTC6); +DigitalOut led1(LED_RED); +DigitalOut led2(LED_BLUE); +DigitalOut led3(LED_GREEN); int main() -{ - DigitalOut led(LED_RED); +{ led3.write(0); pc.baud(115200); float cycle = 0.6;//define the speed of the motor int motor1_on = 0; @@ -23,7 +25,9 @@ motor1_dir=!motor1_dir; } while(button1.read() == motor1_on){// turn on motor 1 when the button is being pressed - DigitalOut led(LED_BLUE); + led3.write(1); + led1.write(0); + direction1.write(motor1_dir);//turn motor CCW or CW if set to 0 //motor CW = 0 //motor CCW = 1