First mbed program example and usage

Dependencies:   mbed

Fork of HelloWorld by Simon Ford

main.cpp

Committer:
efoster79
Date:
2014-10-18
Revision:
3:26b01dec4312
Parent:
2:9debb94a4c8c
Child:
4:48af6a1a72c6

File content as of revision 3:26b01dec4312:

#include "mbed.h"

#define TOTAL_LEDS 4

DigitalOut outleds[TOTAL_LEDS] = { LED1, LED2, LED3, LED4 };

int main() {
    
    int last_selected = 1;
    int i;
    
    while(1) {
        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);
        if(last_selected++ >= TOTAL_LEDS)
            last_selected = 1;    
    }
}