Luuk Blaauw
/
Lampje_kleuren
Lamp kleuren aansturen (werkt nog niet helemaal)
Diff: main.cpp
- Revision:
- 0:fc7212e4505a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 15 16:17:59 2016 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" +#include "MODSERIAL.h" + +DigitalOut rood(LED_RED); +DigitalOut groen(LED_GREEN); +DigitalOut blauw(LED_BLUE); +MODSERIAL pc(USBTX,USBRX); + +int main() +{ + pc.baud(9600); + pc.printf("Hello World/r/n"); + + rood = 1; + groen = 1; + blauw = 1; + + while (true) + { + char c = pc.getc(); + if (c == 'r') + { + groen = 1; + blauw = 1; + while (true) + { + rood = !rood; + wait(0.2f); + }; + } + else if (c == 'g') + { + rood = 1; + blauw = 1; + while (true) + { + groen = !groen; + wait(0.2f); + }; + } + else if (c == 'b') + { + rood = 1; + groen = 1; + while (true) + { + blauw = !blauw; + wait(0.2f); + }; + }; + }; +} \ No newline at end of file