Met kinematics
Dependencies: MODSERIAL QEI mbed-dsp mbed
Fork of Motorcode by
main.cpp
- Committer:
- SimonRez
- Date:
- 2018-09-12
- Revision:
- 4:651d06e860e7
- Parent:
- 3:40a25c2c24ba
- Child:
- 5:f07bafaf11d7
File content as of revision 4:651d06e860e7:
#include "mbed.h" #include "MODSERIAL.h" Ticker Blinker; DigitalOut ledr(LED_RED); DigitalOut ledg(LED_GREEN); DigitalOut ledb(LED_BLUE); InterruptIn sw2(SW2); InterruptIn sw3(SW3); MODSERIAL pc(USBTX, USBRX); volatile char c; volatile char color; void Buttonpress() { if (c == 'r') { color = 'r'; } else if (c == 'g') { color = 'g'; } else if (c == 'b') { color = 'b'; } else if (c == NULL) { ledr = 1; ledg = 1; ledb = 1; } else { pc.printf("Character %c is not valid \r\n",c); c = color; ledr = 0; ledg = 0; ledb = 0; wait(0.1f); ledr = 1; ledg = 1; ledb = 1; wait(0.1f); ledr = 0; ledg = 0; ledb = 0; wait(0.1f); ledr = 1; ledg = 1; ledb = 1; wait(0.1f); ledr = 0; ledg = 0; ledb = 0; wait(0.1f); ledr = 1; ledg = 1; ledb = 1; wait(0.1f); } if (color == 'r') { ledr = !ledr; ledg = 1; ledb = 1; } else if (color == 'g') { ledr = 1; ledg = !ledg; ledb = 1; } else if (color == 'b') { ledr = 1; ledg = 1; ledb = !ledb; } wait(0.25f); ledr = 1; ledg = 1; ledb = 1; } 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 ~~~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(Buttonpress, 0.5); sw2.fall(CurrentColor); sw3.rise(LEDOFF); while (true) { c = pc.getc(); } }