Werkend motorscript met led feedback
Dependencies: Encoder MODSERIAL mbed
Diff: main.cpp
- Revision:
- 3:051c91b04acd
- Parent:
- 2:2b8a8be38c85
diff -r 2b8a8be38c85 -r 051c91b04acd main.cpp --- a/main.cpp Mon Sep 21 11:14:12 2015 +0000 +++ b/main.cpp Mon Sep 21 11:16:34 2015 +0000 @@ -3,42 +3,29 @@ #include "MODSERIAL.h" Serial pc(USBTX, USBRX); // tx, rx -DigitalOut led1(LED_RED); -DigitalOut led2(LED_BLUE); +DigitalOut led(LED_RED); 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 = 1; + motor2direction = 0; motor2speed = 0; - led1 = ledOff; - led2 = ledOff; + led = 1; pc.baud(9600); while(true) { - for(button1 == 0); + if(button1 == 0) { + motor2direction = 1; motor2speed = 0.5f; pc.printf("het werkt"); wait(1); - led1 = ledOn; + led = 0; wait(0.2f); motor2speed = 0; - led1 = ledOff; + led = 1; } - for(button2 == 0); - { - motor2speed = 1; - led2 = ledOn; - wait(0.5f); - led2 = ledOff; - } - } } \ No newline at end of file