blink an led

Dependencies:   mbed

Committer:
maclobdell
Date:
Tue May 10 16:46:53 2016 +0000
Revision:
1:c14fc6db8e1f
Parent:
0:232d11a32e07
tested, removed code to be added by attendees

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maclobdell 0:232d11a32e07 1 #include "mbed.h" // this tells us to load mbed related functions
maclobdell 0:232d11a32e07 2
maclobdell 0:232d11a32e07 3 DigitalOut red(LED_RED); // we create a variable 'red', use it as an out port
maclobdell 0:232d11a32e07 4 Ticker flipper; //Ticker = recurring interrupt to repeatedly call a function at a specified rate
maclobdell 0:232d11a32e07 5
maclobdell 0:232d11a32e07 6 // YOUR CODE HERE
maclobdell 0:232d11a32e07 7
maclobdell 0:232d11a32e07 8 // this code runs when the microcontroller starts up
maclobdell 0:232d11a32e07 9 int main() {
maclobdell 0:232d11a32e07 10 red = 1; //turn the led off, (1=off, I know it's weird)
maclobdell 0:232d11a32e07 11
maclobdell 0:232d11a32e07 12 // we want to blink an led, every 500 ms.
maclobdell 1:c14fc6db8e1f 13 flipper.attach(&blinky, 0.5); // the address of the function to be attached (flip) and the interval (in seconds)
maclobdell 1:c14fc6db8e1f 14
maclobdell 0:232d11a32e07 15 // spin in a main loop. flipper will interrupt it to call flip
maclobdell 0:232d11a32e07 16 while(1) {}
maclobdell 0:232d11a32e07 17 }