Mac Lobdell / Mbed 2 deprecated 2_two_buttons

Dependencies:   mbed

Fork of 2_two_buttons by MakingMusicWorkshop

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

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 }