![](/media/cache/profiles/dream_vangogh.jpg.50x50_q85.jpg)
Touch sensor example for NXP Rapid IoT prototyping kit. Read more at https://www.hackster.io/marcomerli/riotwear-mbed-2b2011.
main.cpp@79:0431b9fd3dc0, 2019-11-23 (annotated)
- Committer:
- batman52
- Date:
- Sat Nov 23 18:03:20 2019 +0000
- Revision:
- 79:0431b9fd3dc0
- Parent:
- 78:ddf5cff958fa
- Child:
- 80:0f41eaa54a9b
added green led
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jonathan Austin |
0:2757d7abb7d9 | 1 | #include "mbed.h" |
Jonathan Austin |
0:2757d7abb7d9 | 2 | |
batman52 | 79:0431b9fd3dc0 | 3 | DigitalOut rgb_red(LED_RED, 1); // LED1 = LED_RED, 1 --> OFF, 0 --> ON |
batman52 | 79:0431b9fd3dc0 | 4 | DigitalOut rgb_blue(LED_BLUE, 1); // LED3 = LED_BLUE, 1 --> OFF, 0 --> ON |
batman52 | 79:0431b9fd3dc0 | 5 | DigitalOut rgb_green(PTE7,1); // 1 --> OFF, 0 --> ON |
batman52 | 79:0431b9fd3dc0 | 6 | |
batman52 | 79:0431b9fd3dc0 | 7 | void rgb_sel(int8_t idx) { |
batman52 | 79:0431b9fd3dc0 | 8 | |
batman52 | 79:0431b9fd3dc0 | 9 | switch(idx) { |
batman52 | 79:0431b9fd3dc0 | 10 | case 0: |
batman52 | 79:0431b9fd3dc0 | 11 | rgb_red = 0; rgb_blue=1; rgb_green = 1; |
batman52 | 79:0431b9fd3dc0 | 12 | break; |
batman52 | 79:0431b9fd3dc0 | 13 | case 1: |
batman52 | 79:0431b9fd3dc0 | 14 | rgb_red = 1; rgb_blue=0; rgb_green = 1; |
batman52 | 79:0431b9fd3dc0 | 15 | break; |
batman52 | 79:0431b9fd3dc0 | 16 | case 2: |
batman52 | 79:0431b9fd3dc0 | 17 | rgb_red = 1; rgb_blue=1; rgb_green = 0; |
batman52 | 79:0431b9fd3dc0 | 18 | break; |
batman52 | 79:0431b9fd3dc0 | 19 | } |
batman52 | 79:0431b9fd3dc0 | 20 | |
batman52 | 79:0431b9fd3dc0 | 21 | } |
Jonathan Austin |
0:2757d7abb7d9 | 22 | |
Jonathan Austin |
1:846c97078558 | 23 | // main() runs in its own thread in the OS |
Jonathan Austin |
0:2757d7abb7d9 | 24 | int main() { |
batman52 | 79:0431b9fd3dc0 | 25 | int idx; |
Jonathan Austin |
0:2757d7abb7d9 | 26 | while (true) { |
batman52 | 79:0431b9fd3dc0 | 27 | for(idx=0;idx<3;idx++) { |
batman52 | 79:0431b9fd3dc0 | 28 | rgb_sel(idx); |
batman52 | 79:0431b9fd3dc0 | 29 | wait(0.5); |
batman52 | 79:0431b9fd3dc0 | 30 | } |
Jonathan Austin |
0:2757d7abb7d9 | 31 | } |
batman52 | 79:0431b9fd3dc0 | 32 | } |