Edwin Foster
/
HelloWorld
First mbed program example and usage
Fork of HelloWorld by
Diff: main.cpp
- Revision:
- 3:26b01dec4312
- Parent:
- 2:9debb94a4c8c
- Child:
- 4:48af6a1a72c6
--- a/main.cpp Sat Oct 18 13:19:48 2014 +0000 +++ b/main.cpp Sat Oct 18 14:20:50 2014 +0000 @@ -1,15 +1,26 @@ #include "mbed.h" -DigitalOut outled1(LED1); -DigitalOut outled3(LED3); +#define TOTAL_LEDS 4 + +DigitalOut outleds[TOTAL_LEDS] = { LED1, LED2, LED3, LED4 }; int main() { + + int last_selected = 1; + int i; + while(1) { - outled1 = 1; - outled3 = 0; + for(i = 0 ; i < TOTAL_LEDS; i++){ + int value_to_check = i + 1; + if( value_to_check == last_selected){ + outleds[i] = 1; + }else{ + outleds[i] = 0; + } + } + wait(1); - outled1= 0; - outled3 = 1; - wait(1); + if(last_selected++ >= TOTAL_LEDS) + last_selected = 1; } }