ece4180_team / Mbed 2 deprecated Lab3PArt4

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002  
00003 Ticker flipper1;
00004 Ticker flipper2;
00005 Ticker flipper3;
00006 Ticker flipper4;
00007 DigitalOut led1(LED1);
00008 DigitalOut led2(LED2);
00009 DigitalOut led3(LED3);
00010 DigitalOut led4(LED4);
00011 int i = 0;
00012 
00013 void flip2() {
00014     led2 = !led2;
00015 }
00016 void flip1() {
00017     led1 = !led1;
00018 }
00019 void flip3() {
00020     led3 = !led3;
00021 }
00022 void flip4() {
00023     led4 = !led4;
00024 }
00025  
00026 int main() {
00027     flipper2.attach(&flip2, 2 ); // the address of the function to be attached (flip) and the interval (2 seconds)
00028     flipper1.attach(&flip1, 1);
00029     flipper3.attach(&flip3, 4);
00030     flipper4.attach(&flip4, 8);
00031     // spin in a main loop. flipper will interrupt it to call flip
00032     while(1) {
00033       i++;
00034     }
00035 }