-
Notifications
You must be signed in to change notification settings - Fork 2
/
count.c
189 lines (155 loc) · 2.43 KB
/
count.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include <REGX51.H>
sbit rs=P3^2;
sbit rw=P3^3;
sbit en=P3^4;
sfr datas=0xA0;
void lcdinit(void);
void lcdcmd(unsigned char );
void delay(unsigned int del);
void lcddata(unsigned char ldat);
void del1();
void sms1();
void sendd();
void INITLCD()
{
lcdinit();
}
void COMMAND(unsigned char val)
{
lcdcmd(val);
}
void DISPLAY(unsigned char val)
{
lcddata(val);
}
void lcdinit(void)
{
lcdcmd(0x38);
lcdcmd(0x38);
lcdcmd(0x38);
lcdcmd(0x06);
lcdcmd(0x0e);
lcdcmd(0x01);
lcdcmd(0x0C);
lcdcmd(0x80);
}
void lcdcmd(unsigned char lcmd)
{
datas=lcmd;
rs=0;
rw=0;
en=1;
delay(100);
en=0;
}
void delay(unsigned int del)
{
while(del--);
}
void lcddata(unsigned char ldat)
{
datas=ldat;
rs=1;
rw=0;
en=1;
delay(100);
en=0;
}
char flags=0;
char flagt=0;
char kval=0;
char flagr=0;
int recharge=0;
char flagtick=0;
unsigned char keypad();
void disp(unsigned char dat)
{
DISPLAY(dat);
}
void cls()
{
COMMAND(0x01);
COMMAND(0x02);
COMMAND(0x80);
}
void putchar(unsigned char val[16],char len)
{
char i;
for(i=0;i<len;i++)
{
disp(val[i]);
}
}
void txs(unsigned char val)
{
int i;
TI=0;
SBUF=val;
for(i=0;i<600;i++);
//while(TI==0);
}
unsigned int val,value,ct,fg,i=0,j;
int ps;
int hb,hbt,hbtt;
void main()
{
unsigned int flg=0,flg1=0;
SCON=0x50;
TMOD=0x20;
TH1=0xfd;
TR1=1;
INITLCD();
lcdcmd(0x80);
putchar("Speed= ",16);
lcdcmd(0x88);
lcddata((val/100)+0x30);
lcddata(((val%100)/10)+0x30);
lcddata((val%10)+0x30);
lcddata(' ');
lcddata('r');
lcddata('p');
lcddata('m');
while(1)
{
if(P1_1==1)
{
if(ps==0)
{
ps=1;
hb++;
}
}
else
{
ps=0;
}
hbt++;
lcdcmd(0xC8);
lcddata(' ');
lcddata(' ');
lcddata(' ');
lcdcmd(0xC8);
lcddata(' ');
lcddata(' ');
lcddata(' ');
if(hbt>600)
{
val=hb*3;
hbt=0;
hb=0;
lcdcmd(0x88);
lcddata((val/100)+0x30);
lcddata(((val%100)/10)+0x30);
lcddata((val%10)+0x30);
lcddata(' ');
lcddata('r');
lcddata('p');
lcddata('m');
if(val>150)
P1_0=0;
else
P1_0=1;
}
}
}
//ABCDEFGHIJKLMNOPQRSTUVWXYZ