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
main.cpp
00001 #include "mbed.h" // this tells us to load mbed related functions 00002 00003 DigitalOut red(LED_RED); // we create a variable 'red', use it as an out port 00004 Ticker flipper; //Ticker = recurring interrupt to repeatedly call a function at a specified rate 00005 00006 // YOUR CODE HERE 00007 00008 //REMOVE 00009 static void blinky() { 00010 // the LED is either on or off (a 1 or a 0). We can inverse the value with the `!` (inverse operator). 00011 // the flipped value is what we write back to the LED, thus toggling the LED. 00012 red = !red; 00013 } 00014 //END_REMOVE 00015 00016 // this code runs when the microcontroller starts up 00017 int main() { 00018 red = 1; //turn the led off, (1=off, I know it's weird) 00019 00020 // we want to blink an led, every 500 ms. 00021 flipper.attach(&blinky, 0.5); // the address of the function to be attached (flip) and the interval (in seconds) 00022 00023 // spin in a main loop. flipper will interrupt it to call flip 00024 while(1) {} 00025 }
Generated on Wed Jul 13 2022 02:26:32 by
1.7.2
