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.
Keepad.cpp
00001 #include "mbed.h" 00002 #include "Keepad.h" 00003 #include "LCDs.h" 00004 00005 DigitalIn bi1(PC_8); 00006 DigitalIn bi2(PC_6); 00007 DigitalIn bi3(PC_5); 00008 DigitalIn bi4(PB_1); 00009 DigitalOut bo1(PA_12); 00010 DigitalOut bo2(PA_11); 00011 DigitalOut bo3(PB_12); 00012 DigitalOut bo4(PB_11); 00013 00014 int g = 0; 00015 00016 Keepad::Keepad(){} 00017 00018 int Keepad::keypad() 00019 { 00020 g=7; 00021 LCDs t2; 00022 //t2.lcdcmd(0x01); 00023 wait_ms(10); 00024 g=5; 00025 int i=0; 00026 00027 bo1 = 1; 00028 bo2 = 0; 00029 bo3 = 0; 00030 bo4 = 0; 00031 keypadIn(); 00032 if(g!=5) 00033 { 00034 t2.putString("A"); 00035 i=10+g; 00036 wait_ms(500); 00037 return(i); 00038 } 00039 00040 bo1 = 0; 00041 bo2 = 1; 00042 bo3 = 0; 00043 bo4 = 0; 00044 keypadIn(); 00045 if(g!=5) 00046 { 00047 t2.putString("B"); 00048 i=20+g; 00049 wait_ms(500); 00050 return(i); 00051 } 00052 00053 bo1 = 0; 00054 bo2 = 0; 00055 bo3 = 1; 00056 bo4 = 0; 00057 keypadIn(); 00058 if(g!=5) 00059 { 00060 t2.putString("C"); 00061 i=30+g; 00062 wait_ms(500); 00063 return(i); 00064 } 00065 00066 bo1 = 0; 00067 bo2 = 0; 00068 bo3 = 0; 00069 bo4 = 1; 00070 keypadIn(); 00071 if(g!=5) 00072 { 00073 t2.putString("D"); 00074 i=40+g; 00075 wait_ms(500); 00076 return(i); 00077 } 00078 return(0); 00079 } 00080 00081 void Keepad::keypadIn() 00082 { 00083 LCDs t3; 00084 for(int l=1;l<10;l++) 00085 { 00086 if(bi1 == 1) 00087 { 00088 t3.putString("1"); 00089 g=1; 00090 break; 00091 } 00092 else if(bi2 == 1) 00093 { 00094 t3.putString("2"); 00095 g=2; 00096 break; 00097 } 00098 else if(bi3 == 1) 00099 { 00100 t3.putString("3"); 00101 g=3; 00102 break; 00103 } 00104 else if(bi4 == 1) 00105 { 00106 t3.putString("4"); 00107 g=4; 00108 break; 00109 } 00110 else 00111 {g=5;} 00112 wait_ms(10); 00113 } 00114 }
Generated on Fri Jul 15 2022 03:01:38 by
1.7.2