Dependencies:   mbed

main.cpp

Committer:
annodomini2
Date:
2009-11-20
Revision:
0:1a0d62dc8f06

File content as of revision 0:1a0d62dc8f06:

#include "mbed.h"
#include "defines.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

int Led_State = 0;
int counter = 0;
bool reverse = false;

int main() 
{
    while (1) 
    {
        switch(Led_State)
        {
            case 1:
                led1 = ON;
                wait(0.2);
                led1 = OFF;
                Led_State = 2;
            break;
            
            case 2:
                led2 = ON;
                wait(0.2);
                led2 = OFF;
                Led_State = 3;
            break;
            
            case 3:
                led3 = ON;
                wait(0.2);
                led3 = OFF;
                Led_State = 4;
            break;
            
            case 4:
                led4 = ON;
                wait(0.2);
                led4 = OFF;
                
                counter++;
                
                if(counter > 10)
                {
                    Led_State = 0;
                    counter = 0;
                }
                else
                {
                    Led_State = 1;
                }
            break;
            
            default:
                led1 = ON;
                led2 = ON;
                led3 = ON;
                led4 = ON;
                wait(0.5);
                led1 = OFF;
                led2 = OFF;
                led3 = OFF;
                led4 = OFF;
                wait(0.5);
                
                counter++;
                
                if(counter > 10)
                {
                    Led_State = 1;
                    counter = 0;
                }
            break;
        }        
    }
}