Arek Zaluski
/
mbed-os-example-blinky-test
Test
Diff: main.cpp
- Revision:
- 1:e2ef489fd6b6
- Parent:
- 0:d5b4a9f0b98c
- Child:
- 4:1252013e7343
--- a/main.cpp Thu Apr 05 11:41:04 2018 +0000 +++ b/main.cpp Thu Sep 19 12:27:33 2019 +0000 @@ -1,38 +1,5 @@ #include "mbed.h" -DigitalOut led1(LED1); -DigitalOut led2(LED2); -DigitalOut led3(LED3); -Serial device(USBTX, USBRX); // tx, rx -float sleep_time = 1.0; // main() runs in its own thread in the OS int main() { - device.baud(115200); - device.printf("Welcome in serial demo!\n"); - device.printf("Toggle colours:\n"); - device.printf("Type: r - red, g - green, b - blue"); - while (true) { - char c = device.getc(); - if(c == 'r') { - led1 = !led1; - device.printf("Red toggled!"); - } - if(c == 'g') { - led2 = !led2; - device.printf("Green toggled!"); - } - if(c == 'b') { - led3 = !led3; - device.printf("Blue toggled!"); - } - if(c == 'u') { - sleep_time = sleep_time + 0.1; - device.printf("Blink time increased!"); - } - if(c == 'd' && sleep_time >= 0.1) { - sleep_time = sleep_time - 0.1; - device.printf("Blink time decreased!"); - } - } } -