Arduino_Button_InterruptIn sample code ported.

Dependencies:   mbed

Fork of InterruptIn_HelloWorld by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 InterruptIn button(USER_BUTTON);
00004 DigitalOut led(LED1);
00005 
00006 void buttonPressed()
00007 {
00008     led = 1;
00009 }
00010 
00011 void buttonReleased()
00012 {
00013     led = 0;
00014 }
00015 
00016 void setup()
00017 {
00018     // button.mode(PullUp);
00019     button.rise(&buttonReleased);  // attach the address of the buttonReleased function to the rising edge
00020     button.fall(&buttonPressed);  // attach the address of the buttonPressed function to the falling edge
00021 }
00022 
00023 void loop()
00024 {
00025     // put your main code here, to run repeatedly:
00026 
00027 }
00028 
00029 int main()
00030 {
00031     setup();
00032     while(1) loop();
00033 }