asking if the button is released

Dependencies:   Hotboards_buttons mbed

Files at this revision

API Documentation at this revision

Comitter:
RomanValenciaP
Date:
Mon Feb 29 20:56:59 2016 +0000
Commit message:
first release - recquires approval

Changed in this revision

Hotboards_buttons.lib Show annotated file Show diff for this revision Revisions of this file
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 6346669b34d4 Hotboards_buttons.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hotboards_buttons.lib	Mon Feb 29 20:56:59 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/Hotboards/code/Hotboards_buttons/#810519ce94bf
diff -r 000000000000 -r 6346669b34d4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 29 20:56:59 2016 +0000
@@ -0,0 +1,33 @@
+
+/*
+ * Toggle led ON pin PA_5 (LED1) when the button on pin PB_4 is released
+ */
+ 
+#include "mbed.h"
+#include "Hotboards_buttons.h"
+
+//Creates a single button object, when the button is pressed it gives you
+//a LOW(0) value because it works with pull-ups.
+Hotboards_buttons btn( PB_4 );
+//If your buttons gives you a HIGH(1) value when is pressed, then we need
+//to create the button object with and extra parameter:
+//Hotboards_buttons btn( PB_4 , 1 ); in any case the functions will return
+//a HIGH(1) value any time the button is pressed
+
+//To our example we will use the led on the nucleo board
+DigitalOut nucleoLed( LED1 );
+
+int main()
+{
+    while(1)
+    {
+        //The moment when the button is released the function will return a HIGH(1)
+        //value, it doesn`t matter if your button is configured with pull-ups(LOW)
+        //or pull-downs(HIGH)
+        if( btn.isReleased( ) )
+        {
+            //Toggle led on the nucleo board
+            nucleoLed = !nucleoLed;
+        }       
+    }
+}
diff -r 000000000000 -r 6346669b34d4 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 29 20:56:59 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file