![](/media/cache/profiles/dream_vangogh.jpg.50x50_q85.jpg)
NXP Rapid IoT prototiping kit ticker example.
Diff: main.cpp
- Revision:
- 79:0431b9fd3dc0
- Parent:
- 78:ddf5cff958fa
- Child:
- 80:9b1ada9b98e1
diff -r ddf5cff958fa -r 0431b9fd3dc0 main.cpp --- a/main.cpp Wed Nov 20 21:33:47 2019 +0000 +++ b/main.cpp Sat Nov 23 18:03:20 2019 +0000 @@ -1,14 +1,32 @@ #include "mbed.h" -DigitalOut led_red(LED_RED, 1); // LED1 = LED_RED, 1 --> OFF, 0 --> ON -DigitalOut led_blue(LED_BLUE, 1); // LED3 = LED_BLUE, 1 --> OFF, 0 --> ON +DigitalOut rgb_red(LED_RED, 1); // LED1 = LED_RED, 1 --> OFF, 0 --> ON +DigitalOut rgb_blue(LED_BLUE, 1); // LED3 = LED_BLUE, 1 --> OFF, 0 --> ON +DigitalOut rgb_green(PTE7,1); // 1 --> OFF, 0 --> ON + +void rgb_sel(int8_t idx) { + +switch(idx) { + case 0: + rgb_red = 0; rgb_blue=1; rgb_green = 1; + break; + case 1: + rgb_red = 1; rgb_blue=0; rgb_green = 1; + break; + case 2: + rgb_red = 1; rgb_blue=1; rgb_green = 0; + break; + } + +} // main() runs in its own thread in the OS int main() { + int idx; while (true) { - led_red = !led_red; - led_blue = !led_red; - wait(0.5); + for(idx=0;idx<3;idx++) { + rgb_sel(idx); + wait(0.5); + } } -} - +} \ No newline at end of file