NUCLEO-F042K6 Simple demo with button pooling input
Dependencies: mbed
Fork of mbed_button_simple by
Diff: main.cpp
- Revision:
- 0:3d66dff04e7d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Feb 17 18:18:23 2018 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +/******************************************************************************* + + EXAMPLE DESCRIPTION + + Sets digital in on PA_0 with internal pull up. State of digital in is + periodically read in main program loop. When button is pressed, onboard LED + is toggled. + +*******************************************************************************/ +DigitalIn button(PA_0, PullUp); // deffition of interrupt + +DigitalOut LED(LED1); // definition of digital out pin + +int main() +{ + bool set= false; // LED already toggled + + while(1) { + if(button==0 && !set){ + LED=!LED; + set=true; + }else if(button==1 && set){ + set=false; + } + + wait_ms(1); + } + +}