Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 4:4afc587630ea
- Parent:
- 3:68d78770639b
- Child:
- 5:dc3a076bbb10
--- a/main.cpp Tue Sep 10 15:26:58 2019 +0000
+++ b/main.cpp Tue Sep 10 18:27:43 2019 +0000
@@ -7,30 +7,33 @@
DigitalOut ledb(LED_BLUE);
Ticker ReadEnCoder;
-volatile char color;
+char color;
void flicker()
{
- ledr = !ledr;
- ledg = !ledg;
- ledb = !ledb;
+ if (color == 'r') {
+ ledr=!ledr;
+ ledg=1;
+ ledb=1;
+ }
+ if (color == 'g') {
+ ledr=1;
+ ledg=!ledg;
+ ledb=1;
+ }
+ if (color == 'b') {
+ ledr=1;
+ ledg=1;
+ ledb=!ledb;
+ }
}
int main()
{
pc.baud(115200);
- while (true)
- {
+ while (true) {
+ pc.printf("%c\n\r",color);
ReadEnCoder.attach(flicker,0.5);
color = pc.getc();
- if (color == 'r'){
- ledr=!ledr;
- }
- if (color == 'g'){
- ledg=!ledg;
- }
- if (color == 'b'){
- ledb=!ledb;
- }
}
}
\ No newline at end of file