Pieter Vandevoorde
/
mbed-os-example-red_green_blue
blinky with 3 colors
Fork of mbed-os-example-mbed5-blinky by
main.cpp@18:d15cf1cad4c9, 2016-11-16 (annotated)
- Committer:
- Pieter56
- Date:
- Wed Nov 16 21:09:41 2016 +0000
- Revision:
- 18:d15cf1cad4c9
- Parent:
- 17:f1532314d1a9
- Child:
- 19:ff7ac8de56f9
Display RGB 7 colors
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 | |
Pieter56 | 17:f1532314d1a9 | 3 | DigitalOut led1(LED1, 0); |
Pieter56 | 18:d15cf1cad4c9 | 4 | DigitalOut led2(LED2, 0); |
Pieter56 | 18:d15cf1cad4c9 | 5 | DigitalOut led3(LED3, 0); |
Jonathan Austin |
1:846c97078558 | 6 | // main() runs in its own thread in the OS |
Jonathan Austin |
1:846c97078558 | 7 | // (note the calls to Thread::wait below for delays) |
Pieter56 | 18:d15cf1cad4c9 | 8 | |
Jonathan Austin |
0:2757d7abb7d9 | 9 | int main() { |
Pieter56 | 18:d15cf1cad4c9 | 10 | uint16_t color = 0; |
Jonathan Austin |
0:2757d7abb7d9 | 11 | while (true) { |
Pieter56 | 17:f1532314d1a9 | 12 | Thread::wait(1000); |
Pieter56 | 18:d15cf1cad4c9 | 13 | //led1 = !led1; |
Pieter56 | 18:d15cf1cad4c9 | 14 | //led2 = !led2; |
Pieter56 | 18:d15cf1cad4c9 | 15 | color++; |
Pieter56 | 18:d15cf1cad4c9 | 16 | color = color & 0x7; |
Pieter56 | 18:d15cf1cad4c9 | 17 | led1 = color & 0x1; |
Pieter56 | 18:d15cf1cad4c9 | 18 | led2 = (color >> 1) & 0x1; |
Pieter56 | 18:d15cf1cad4c9 | 19 | led3 = (color >> 2) & 0x1; |
Jonathan Austin |
0:2757d7abb7d9 | 20 | } |
Jonathan Austin |
0:2757d7abb7d9 | 21 | } |
Jonathan Austin |
1:846c97078558 | 22 |