Basic example showing how to drive the four LEDs.
Dependencies: mbed
main.cpp@1:ffce5529b273, 2017-06-06 (annotated)
- Committer:
- arostm
- Date:
- Tue Jun 06 15:49:20 2017 +0200
- Revision:
- 1:ffce5529b273
- Parent:
- 0:885c37e1d765
Adding new mbed library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:885c37e1d765 | 1 | #include "mbed.h" |
bcostm | 0:885c37e1d765 | 2 | |
bcostm | 0:885c37e1d765 | 3 | DigitalOut led_green(LED1); |
bcostm | 0:885c37e1d765 | 4 | DigitalOut led_orange(LED2); |
bcostm | 0:885c37e1d765 | 5 | DigitalOut led_red(LED3); |
bcostm | 0:885c37e1d765 | 6 | DigitalOut led_blue(LED4); |
bcostm | 0:885c37e1d765 | 7 | |
bcostm | 0:885c37e1d765 | 8 | int main() { |
bcostm | 0:885c37e1d765 | 9 | while(1) { |
bcostm | 0:885c37e1d765 | 10 | // WARNING: LEDs are OFF |
bcostm | 0:885c37e1d765 | 11 | led_green = 1; |
bcostm | 0:885c37e1d765 | 12 | led_orange = 1; |
bcostm | 0:885c37e1d765 | 13 | led_red = 1; |
bcostm | 0:885c37e1d765 | 14 | led_blue = 1; |
bcostm | 0:885c37e1d765 | 15 | wait(0.2); // 200 ms |
bcostm | 0:885c37e1d765 | 16 | // WARNING: LEDs are ON |
bcostm | 0:885c37e1d765 | 17 | led_green = 0; |
bcostm | 0:885c37e1d765 | 18 | led_orange = 0; |
bcostm | 0:885c37e1d765 | 19 | led_red = 0; |
bcostm | 0:885c37e1d765 | 20 | led_blue = 0; |
bcostm | 0:885c37e1d765 | 21 | wait(1.0); // 1 sec |
bcostm | 0:885c37e1d765 | 22 | } |
bcostm | 0:885c37e1d765 | 23 | } |