Ticker Example

Fork of Workshop-1-Example-2 by mbed Workshops

main.cpp

Committer:
thinkfire
Date:
2017-01-20
Revision:
1:965926ce34a0
Parent:
0:41a092c2e9d3

File content as of revision 1:965926ce34a0:

#include "mbed.h"
 
Serial pc(USBTX,USBRX);

Ticker L1,L2,L3,L4;

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
 
void led_1() {
    led1 = !led1;
    //pc.printf("LED 1 toogled\n");
}
 
void led_2() {
    led2 = !led2;
    //pc.printf("LED 2 toogled\n");
}

void led_3() {
    led3 = !led3;
   // pc.printf("LED 3 toogled\n");
}

void led_4() {
    led4 = !led4;
   // pc.printf("LED 4 toogled\n");
}
 
int main() {
    L1.attach(&led_1, ((rand()%10)+1));
    L2.attach(&led_2, ((rand()%10)+1)); // call flip function every 2 seconds 
    L3.attach(&led_3, ((rand()%10)+1));
    L4.attach(&led_4, ((rand()%10)+1));

    // spin in a main loop. flipper will interrupt it to call flip
    while(1) {
      
       }
}