Temi Solesi / Mbed 2 deprecated 1620_App_Board_Buttons

Dependencies:   mbed

Fork of 1620_App_Board_Buttons by Craig Evans

Files at this revision

API Documentation at this revision

Comitter:
eencae
Date:
Fri Feb 17 11:13:02 2017 +0000
Child:
1:f650db6c33e4
Commit message:
Initial commit.

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Feb 17 11:13:02 2017 +0000
@@ -0,0 +1,44 @@
+/* ELEC1620 Application Board Example
+
+Buttons
+
+(c) Dr Craig A. Evans, University of Leeds, Feb 2017
+
+*/
+
+#include "mbed.h"
+
+DigitalIn button_A(p29);
+DigitalIn button_B(p28);
+DigitalIn button_C(p27);
+DigitalIn button_D(p26);
+
+int main() {
+    
+    while(1) {
+        
+        // read each of the buttons and store in variable
+        int button_A_value = button_A.read();
+        // int button_A_value = button_A;  // this is equivalent
+        int button_B_value = button_B.read();
+        int button_C_value = button_C.read();
+        int button_D_value = button_D.read();
+        
+        // check if pressed (value will be 1 i.e. true) and print message
+        if (button_A_value) {
+            printf("Button A is pressed\n");    
+        }
+        if (button_B_value) {
+            printf("Button B is pressed\n");    
+        }
+        if (button_C_value) {
+            printf("Button C is pressed\n");    
+        }
+        if (button_D_value) {
+            printf("Button D is pressed\n");    
+        }
+        
+        wait(0.5);  // small delay - won't be able to read button during delay
+        
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 17 11:13:02 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f
\ No newline at end of file