pot controller voor positie, kp handmatig instellen, werkt met motor 1 en 2
Dependencies: MODSERIAL QEI mbed-dsp mbed
Fork of PI_controller_verbeteringen by
Diff: main.cpp
- Revision:
- 4:651d06e860e7
- Parent:
- 3:40a25c2c24ba
- Child:
- 5:f07bafaf11d7
--- a/main.cpp Wed Sep 12 11:52:10 2018 +0000 +++ b/main.cpp Wed Sep 12 12:18:25 2018 +0000 @@ -6,14 +6,16 @@ DigitalOut ledr(LED_RED); DigitalOut ledg(LED_GREEN); DigitalOut ledb(LED_BLUE); -DigitalIn sw2(PTC6); + +InterruptIn sw2(SW2); +InterruptIn sw3(SW3); MODSERIAL pc(USBTX, USBRX); volatile char c; volatile char color; -void ButtonpressCheck() +void Buttonpress() { if (c == 'r') { @@ -82,6 +84,7 @@ ledg = 1; ledb = !ledb; } + wait(0.25f); ledr = 1; ledg = 1; @@ -89,24 +92,54 @@ } +void CurrentColor() +{ + if (color == 'r') + { + pc.printf("The current blinking color is: red. \r\n"); + } + else if (color == 'g') + { + pc.printf("The current blinking color is: green. \r\n"); + } + else if (color == 'b') + { + pc.printf("The current blinking color is: blue. \r\n"); + } + else + { + pc.printf("The LED is currently not blinking.\r\n"); + } +} + +void LEDOFF() +{ + color = NULL; + c = NULL; + + ledr = 1; + ledg = 1; + ledb = 1; +} + int main() { ledr = 1; ledg = 1; ledb = 1; - pc.printf("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ~~~Pu$$Y~~~ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"); + pc.printf("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ~~~A$$De$troyer69~~~ \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"); pc.baud(115200); - Blinker.attach(ButtonpressCheck, 0.5); - + Blinker.attach(Buttonpress, 0.5); + sw2.fall(CurrentColor); + sw3.rise(LEDOFF); while (true) { c = pc.getc(); - } }