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.
Polling.cpp
00001 #include "mbed.h" 00002 00003 DigitalIn P5(p5); //connected to 1kohms resistor and PIN5 of the keypad 00004 DigitalIn P6(p6); //connected to 1kohms resistor and PIN6 of the keypad 00005 DigitalOut P7(p7);//connected to PIN8 of the keypad 00006 DigitalOut P8(p8);//connected to PIN4 of the keypad 00007 DigitalOut Led1(LED1); 00008 DigitalOut Led2(LED2); 00009 00010 int main() 00011 { 00012 //set on both PIN8 and PIN4 of the keypad to detect which button is pressed. 00013 P7 = 1; 00014 P8 = 1; 00015 while(1) { 00016 if (P5 == 1) //LED1 is on when Button "2" is pressed 00017 Led1 = 1; 00018 else if(P6 == 1)//LED2 is on when Button "#" is pressed 00019 Led2 = 1; 00020 else { //set LEDs off if no button is pressed 00021 Led1 = 0; 00022 Led2 = 0; 00023 } 00024 } 00025 } 00026
Generated on Thu Jul 14 2022 03:23:13 by
1.7.2