Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of 1_blinky by
Diff: main.cpp
- Revision:
- 0:232d11a32e07
- Child:
- 1:641d32f7b4ec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon May 09 19:47:06 2016 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h" // this tells us to load mbed related functions
+
+DigitalOut red(LED_RED); // we create a variable 'red', use it as an out port
+Ticker flipper; //Ticker = recurring interrupt to repeatedly call a function at a specified rate
+
+void flip() {
+ red = !red;
+}
+
+// YOUR CODE HERE
+
+// this code runs when the microcontroller starts up
+int main() {
+ red = 1; //turn the led off, (1=off, I know it's weird)
+
+ // we want to blink an led, every 500 ms.
+ flipper.attach(&flip, 0.5); // the address of the function to be attached (flip) and the interval (in seconds)
+
+ // spin in a main loop. flipper will interrupt it to call flip
+ while(1) {}
+}
