Simple demo with button pooling input

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
vodsejak
Date:
Sat Feb 17 18:18:23 2018 +0000
Commit message:
v1.0;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 3d66dff04e7d main.cpp
--- /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);
+    }
+
+}
diff -r 000000000000 -r 3d66dff04e7d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 17 18:18:23 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file