First mbed program example and usage

Dependencies:   mbed

Fork of HelloWorld by Simon Ford

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #define TOTAL_LEDS 4
00004 
00005 DigitalOut outleds[TOTAL_LEDS] = { LED1, LED2, LED3, LED4 };
00006 
00007 int main() {
00008     
00009     int last_selected = 1;
00010     int i;
00011     
00012     while(1) {
00013         for(i = 0 ; i < TOTAL_LEDS; i++){
00014             int value_to_check = i + 1;
00015             outleds[i] = value_to_check == last_selected ? 1 : 0;
00016         }
00017         
00018         wait(1);
00019         
00020         if(last_selected++ >= TOTAL_LEDS)
00021             last_selected = 1;    
00022     }
00023 }