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 2_two_buttons 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 DigitalOut green(LED_GREEN); // we create a variable 'green', use it as an out port 00005 00006 InterruptIn btn2(SW2); // we create a variable 'btn2', use it as an in port 00007 InterruptIn btn3(SW3); // we create a variable 'btn3', use it as an in port 00008 00009 // YOUR CODE HERE 00010 //REMOVE 00011 static void toggle_red() { 00012 red = !red; 00013 } 00014 static void toggle_green() { 00015 green = !green; 00016 } 00017 //END REMOVE 00018 00019 // this code runs when the microcontroller starts up 00020 int main() { 00021 green = red = 1; // turn off green and red on startup (1=off, I know it's weird) 00022 00023 btn2.fall(toggle_red); 00024 btn3.fall(toggle_green); 00025 00026 // spin in a main loop. Wait for interrupts. 00027 while(1) {} 00028 }
Generated on Mon Aug 1 2022 00:25:42 by
1.7.2
