HW3_p1

Dependencies:   mbed

Fork of Ticker_HelloWorld by mbed official

Committer:
lzzcd001
Date:
Mon Feb 23 15:05:08 2015 +0000
Revision:
2:a52bfb4f737b
Parent:
0:5014bf742e9b
HW3_p1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:5014bf742e9b 1 #include "mbed.h"
mbed_official 0:5014bf742e9b 2
lzzcd001 2:a52bfb4f737b 3 Ticker flipper1;
lzzcd001 2:a52bfb4f737b 4 Ticker flipper2;
lzzcd001 2:a52bfb4f737b 5 Ticker flipper3;
lzzcd001 2:a52bfb4f737b 6 Ticker flipper4;
mbed_official 0:5014bf742e9b 7 DigitalOut led1(LED1);
mbed_official 0:5014bf742e9b 8 DigitalOut led2(LED2);
lzzcd001 2:a52bfb4f737b 9 DigitalOut led3(LED3);
lzzcd001 2:a52bfb4f737b 10 DigitalOut led4(LED4);
mbed_official 0:5014bf742e9b 11
lzzcd001 2:a52bfb4f737b 12 void flip1() {
lzzcd001 2:a52bfb4f737b 13 led1 = !led1;
lzzcd001 2:a52bfb4f737b 14 }
lzzcd001 2:a52bfb4f737b 15
lzzcd001 2:a52bfb4f737b 16 void flip2() {
mbed_official 0:5014bf742e9b 17 led2 = !led2;
mbed_official 0:5014bf742e9b 18 }
lzzcd001 2:a52bfb4f737b 19
lzzcd001 2:a52bfb4f737b 20 void flip3() {
lzzcd001 2:a52bfb4f737b 21 led3 = !led3;
lzzcd001 2:a52bfb4f737b 22 }
lzzcd001 2:a52bfb4f737b 23
lzzcd001 2:a52bfb4f737b 24 void flip4() {
lzzcd001 2:a52bfb4f737b 25 led4 = !led4;
lzzcd001 2:a52bfb4f737b 26 }
mbed_official 0:5014bf742e9b 27 int main() {
lzzcd001 2:a52bfb4f737b 28 led1 = 1;
mbed_official 0:5014bf742e9b 29 led2 = 1;
lzzcd001 2:a52bfb4f737b 30 led3 = 1;
lzzcd001 2:a52bfb4f737b 31 led4 = 1;
lzzcd001 2:a52bfb4f737b 32 flipper1.attach(&flip1, 1.0); // the address of the function to be attached (flip) and the interval (2 seconds)
lzzcd001 2:a52bfb4f737b 33 flipper2.attach(&flip2, 2.0);
lzzcd001 2:a52bfb4f737b 34 flipper3.attach(&flip3, 3.0);
lzzcd001 2:a52bfb4f737b 35 flipper4.attach(&flip4, 4.0);
mbed_official 0:5014bf742e9b 36 // spin in a main loop. flipper will interrupt it to call flip
mbed_official 0:5014bf742e9b 37 while(1) {
mbed_official 0:5014bf742e9b 38 }
mbed_official 0:5014bf742e9b 39 }