execute a function when a button is pressed
Dependencies: mbed
main.cpp
- Committer:
- maclobdell
- Date:
- 2016-05-09
- Revision:
- 0:49e04b14e729
File content as of revision 0:49e04b14e729:
#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 DigitalOut green(LED_GREEN); // we create a variable 'green', use it as an out port InterruptIn btn2(SW2); // we create a variable 'btn2', use it as an in port InterruptIn btn3(SW3); // we create a variable 'btn3', use it as an in port // YOUR CODE HERE // this code runs when the microcontroller starts up int main() { green = red = 1; // turn off green and red on startup (1=off, I know it's weird) btn2.fall(toggle_red); btn3.fall(toggle_green); // spin in a main loop. Wait for interrupts. while(1) {} }