Timo de Vries
/
leds_test
push buttons to control the leds
Diff: main.cpp
- Revision:
- 0:026e533b2f2f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Sep 12 09:55:09 2016 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "math.h" + +DigitalOut gpo(D0); +DigitalOut led_g(LED_GREEN); +DigitalOut led_b(LED_BLUE); +DigitalOut led_r(LED_RED); +DigitalIn sw3 (SW3); +DigitalIn sw2(SW2); + +int main() +{ + while (true) { + gpo = !gpo; // toggle pin + led_g = 1; + led_b = 1; + led_r = 1; + + if (sw2 == 0) + { + led_g = 1; + led_b = 0; + led_r = 1; + } + if (sw3 == 0) + { + led_g = 1; + led_b = 1; + led_r = 0; + } + if ((sw2==0)&&(sw3==0)) + { + led_g = 0; + led_b = 1; + led_r = 1; + } + } +} \ No newline at end of file