Code to demonstrate use of the two buttons to toggle LED's

Dependencies:   mbed

Fork of nRF_buttons by UCL IoT

Files at this revision

API Documentation at this revision

Comitter:
smartsystemdesign
Date:
Wed Sep 07 15:48:11 2016 +0000
Parent:
1:0133472f4825
Commit message:
Added the rest of the buttons and LEDs.

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 0133472f4825 -r 2ee8a0e3e3f9 main.cpp
--- a/main.cpp	Fri Dec 12 18:02:52 2014 +0000
+++ b/main.cpp	Wed Sep 07 15:48:11 2016 +0000
@@ -5,31 +5,48 @@
 Last Update: 12.12.2014
 */
 #include "mbed.h"
-/* Define pin names and numbers (I know these probably aren't needed but I put them in to demonstrate pin numbering) */
-#define LED1 p18
-#define LED2 p19
-#define SW1 p16
-#define SW2 p17
+/* Define pin names and numbers */
+
+#define SW4 p16
+#define SW3 p15
+#define SW2 p14
+#define SW1 p13
+
 /*Function Prototypes*/
 void trigger1();//Button1 Interrupt function
 void trigger2();//Button2 Interrup Function
+void trigger3();//Button1 Interrupt function
+void trigger4();//Button2 Interrup Function
 
 //Instantiate IO objects
 DigitalOut led_1(LED1);
 DigitalOut led_2(LED2);
+DigitalOut led_3(LED3);
+DigitalOut led_4(LED4);
+
 DigitalIn  sw_1(SW1);
 DigitalIn  sw_2(SW2);
+DigitalIn  sw_3(SW3);
+DigitalIn  sw_4(SW4);
+
 //Instantiate input interrupts
 InterruptIn sw1Press(SW1);
 InterruptIn sw2Press(SW2);
+InterruptIn sw3Press(SW3);
+InterruptIn sw4Press(SW4);
 
 int main() {
     //Initialise LED output
     led_1=0;
     led_2=0;
-    //Choose falling edge interrupt and connect to apppropriate interrup function
+    led_3=0;
+    led_4=0;
+    
+    //Choose falling edge interrupt and connect to appropriate interrupt function
     sw1Press.fall(&trigger1);
     sw2Press.fall(&trigger2);
+    sw3Press.fall(&trigger3);
+    sw4Press.fall(&trigger4);
     while(1) {}
 }
 /*Button1 interrupt function*/
@@ -41,4 +58,14 @@
 void trigger2()
 {
  led_2=!led_2; 
+}
+/*Button3 interrupt function*/
+void trigger3()
+{
+ led_3=!led_3;
+}
+/*Button4 interrupt function*/
+void trigger4()
+{
+ led_4=!led_4; 
 }
\ No newline at end of file
diff -r 0133472f4825 -r 2ee8a0e3e3f9 mbed.bld
--- a/mbed.bld	Fri Dec 12 18:02:52 2014 +0000
+++ b/mbed.bld	Wed Sep 07 15:48:11 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897
\ No newline at end of file