elektro hiof / Mbed 2 deprecated mbed_5_B_3_a

Dependencies:   mbed

main.cpp

Committer:
JES
Date:
2014-10-30
Revision:
0:e060ec1efa33

File content as of revision 0:e060ec1efa33:

#include "mbed.h"

DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4);
Ticker tick1, tick2, tick3, tick4 ;

volatile int lys1, lys2, lys3, lys4;
Timer timer;

void lyscontroll_1()
{
    lys1=!lys1;
}
void lyscontroll_2()
{
    lys2=!lys2;
}
void lyscontroll_3()
{
    lys3=!lys3;
}
void lyscontroll_4()
{
    lys4=!lys4;
}
int runOnce =1;
int main()
{
    timer.start ();
    tick1.attach(&lyscontroll_1, 1.0/2);
    tick2.attach(&lyscontroll_2, 1.0/6.6);
    tick3.attach(&lyscontroll_3, 1.0/14);
    


    while (1) {
        led1 = lys1;
        led2 = lys2;
        led3 = lys3;
        led4 = lys4;
        if (timer.read()>=10 && runOnce == 1){
    tick4.attach(&lyscontroll_4, 1.0/20);
    runOnce =0;
    }
        if (timer.read() >=10) {
            tick1.detach();
            if (timer.read() >=20) {
                tick2.detach();
                if (timer.read() >=20) {
                    tick3.detach();

                }
            }
        }
    }
}