1#include<LiquidCrystal.h>
2
3LiquidCrystal lcd(2,3,4,5,6,7);
4
5int i=0;
6int ok,cancel,up,down;
7char count[4];
8char count1[4];
9char buffer1[20];
10void setup() {
11
12lcd.begin(16,2);
13lcd.setCursor(0,0);
14lcd.print(" Login pswd ");
15
16pinMode(A0,INPUT_PULLUP);
17pinMode(A1,INPUT_PULLUP);
18pinMode(A2,INPUT_PULLUP);
19pinMode(A3,INPUT_PULLUP);
20
21count[0]='0';
22count[1]='0';
23count[2]='0';
24count[3]='0';
25
26}
27
28void loop() {
29
30while(1)
31{
32ok=digitalRead(A0);
33cancel=digitalRead(A1);
34up=digitalRead(A2);
35down=digitalRead(A3);
36if (ok==LOW)
37{
38 while(digitalRead(A0)==LOW);
39 count1[i]=count[i];
40 count[i]='*';
41 i++;
42
43 if (i>=4)
44 break;
45
46 }
47if (cancel==LOW)
48{
49 while(digitalRead(A1)==LOW);
50 break;
51
52 }
53if (up==LOW)
54{
55 while(digitalRead(A2)==LOW);
56 count[i]++;
57 if(count[i]>'9')
58 count[i]='0';
59
60 }
61if (down==LOW)
62{
63 while(digitalRead(A3)==LOW);
64 count[i]--;
65 if(count[i]<'0')
66 count[i]='9';
67
68 }
69sprintf(buffer1," %c%c%c%c ",count[0],count[1],count[2],count[3]);
70lcd.setCursor(0,1);
71lcd.print(buffer1);
72}
73
74if((count1[0]=='1')&&(count1[1]=='2')&&(count1[2]=='3')&&(count1[3]=='4'))
75{
76lcd.setCursor(0,0);
77lcd.clear();
78lcd.print("Successfully done ");
79 }
80 else
81 {
82lcd.clear();
83lcd.print("faild ");
84 }
85while(1);
86
87}
88