Werkend motorscript met led feedback
Dependencies: Encoder MODSERIAL mbed
Diff: main.cpp
- Revision:
- 2:2b8a8be38c85
- Parent:
- 1:4e65a72b622e
- Child:
- 3:051c91b04acd
--- a/main.cpp Mon Sep 21 10:16:05 2015 +0000 +++ b/main.cpp Mon Sep 21 11:14:12 2015 +0000 @@ -3,29 +3,42 @@ #include "MODSERIAL.h" Serial pc(USBTX, USBRX); // tx, rx -DigitalOut led(LED_RED); +DigitalOut led1(LED_RED); +DigitalOut led2(LED_BLUE); DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield) PwmOut motor2speed(D5); DigitalIn button1(SW3); +DigitalIn button2(SW2); + +const int ledOff = 1; +const int ledOn = 0; int main() { - motor2direction = 0; + motor2direction = 1; motor2speed = 0; - led = 1; + led1 = ledOff; + led2 = ledOff; pc.baud(9600); while(true) { - if(button1 == 0) + for(button1 == 0); { - motor2direction = 1; motor2speed = 0.5f; pc.printf("het werkt"); wait(1); - led = 0; + led1 = ledOn; wait(0.2f); motor2speed = 0; - led = 1; + led1 = ledOff; } + for(button2 == 0); + { + motor2speed = 1; + led2 = ledOn; + wait(0.5f); + led2 = ledOff; + } + } } \ No newline at end of file