Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Part1/Polling.cpp
- Revision:
- 0:217de6e7e29a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Part1/Polling.cpp Thu Jan 29 22:54:57 2015 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+DigitalIn P5(p5); //connected to 1kohms resistor and PIN5 of the keypad
+DigitalIn P6(p6); //connected to 1kohms resistor and PIN6 of the keypad
+DigitalOut P7(p7);//connected to PIN8 of the keypad
+DigitalOut P8(p8);//connected to PIN4 of the keypad
+DigitalOut Led1(LED1);
+DigitalOut Led2(LED2);
+
+int main()
+{
+ //set on both PIN8 and PIN4 of the keypad to detect which button is pressed.
+ P7 = 1;
+ P8 = 1;
+ while(1) {
+ if (P5 == 1) //LED1 is on when Button "2" is pressed
+ Led1 = 1;
+ else if(P6 == 1)//LED2 is on when Button "#" is pressed
+ Led2 = 1;
+ else { //set LEDs off if no button is pressed
+ Led1 = 0;
+ Led2 = 0;
+ }
+ }
+}
+