首页 > > 详细

辅导留学生c设计、c编程解析、辅导c、c讲解

#include
#define uint unsigned int
#define uchr unsigned char
sbit led0=P2^2;
sbit buzzer=P2^3;
sbit dula=P2^6; //
sbit wela=P2^7; //
sbit clear=P3^4;
uchr key,shi,ge,count;
uchr code tab[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,
0x76,0x79,0x38,0x3f};
/*, xms */
void delay(uint xms)
{
uint x,y;
for(x=xms;x>0;x--)
for(y=110;y>0;y--);
}

/* */
void matrixkeyscan()
{
uint temp;
P3=0xf7; // P3
temp=P3;
temp=temp0xf0;
if(temp!=0xf0) //
{
delay(6); //
temp=P3;
temp=temp0xf0;
if(temp!=0xf0) //
{
temp=P3;
switch(temp)
{
case 0x77:
key=1;
break;
case 0xb7:
key=2;
break;
case 0xd7:
key=3;
break;
case 0xe7:
key=4;
break; //
}
while(temp!=0xf0)
{
temp=P3;
temp=temp0xf0;
} //
}
}
P3=0xfb;
temp=P3;
temp=temp0xf0;
if(temp!=0xf0)
{
delay(6);
temp=P3;
temp=temp0xf0;
if(temp!=0xf0)
{
temp=P3;
switch(temp)
{
case 0x7b:
key=5;
break;
case 0xbb:
key=6;
break;
case 0xdb:
key=7;
break;
case 0xeb:
key=8;
break;
}
while(temp!=0xf0)
{
temp=P3;
temp=temp0xf0;
}
}
}
P3=0xfd;
temp=P3;
temp=temp0xf0;
if(temp!=0xf0)
{
delay(6);
temp=P3;
temp=temp0xf0;
if(temp!=0xf0)
{
temp=P3;
switch(temp)
{
case 0x7d:
key=9;
break;
case 0xbd:
key=10;
break;
case 0xdd:
key=11;
break;
case 0xed:
key=12;
break;
}
while(temp!=0xf0)
{
temp=P3;
temp=temp0xf0;
}
}
}
P3=0xfe;
temp=P3;
temp=temp0xf0;
if(temp!=0xf0)
{
delay(6);
temp=P3;
temp=temp0xf0;
if(temp!=0xf0)
{
temp=P3;
switch(temp)
{
case 0x7e:
key=13;
break;
case 0xbe:
key=14;
break;
case 0xde:
key=15;
break;
case 0xee:
key=16;
break;
}
while(temp!=0xf0)
{
temp=P3;
temp=temp0xf0;
}
}
}
}
/* */
void alarm()
{
buzzer=~buzzer;
led0=~led0;
delay(30);
}
void display(uchr num)
{
if(key!=0) //,
{

dula=1;
P0=tab[num/10];
dula=0;
P0=0x00;
wela=1;
P0=0xfe;
wela=0;
delay(100);

dula=1;
P0=tab[num%10];
dula=0;
P0=0x00;
wela=1;
P0=0xfd;
wela=0;
delay(100);
alarm();
}
}
void main()
{
P0=0x00;
while(1)
{
matrixkeyscan();
display(key);
}
}






24 protues
P 0 0
P 0 1
P 0 2
P 0 3
P 0 4
P 0 5
P 0 6
P 0 7
P 0 0
P 0 1
P 0 2
P 0 3
P 0 4
P 0 5
P 0 6
P 0 7
W1
W2P 0 0
P 0 1
P 0 2
P 0 3
P 0 4
P 0 5
P 0 6
P 0 7 DP
G
F
E
D
C
B
A
A B C D E F G D
P
W
1
W
2
X1
CR Y S T A L
C1
3 0 P F
C2
3 0 P F
X T A L 2
18
X T A L 1
19
A L E
30
EA
31
P S E N
29
RS T
9
P 0 .0 /A D 0
39
P 0 .1 /A D 1
38
P 0 .2 /A D 2
37
P 0 .3 /A D 3
36
P 0 .4 /A D 4
35
P 0 .5 /A D 5
34
P 0 .6 /A D 6
33
P 0 .7 /A D 7
32
P 1 .0
1
P 1 .1
2
P 1 .2
3
P 1 .3
4
P 1 .4
5
P 1 .5
6
P 1 .6
7
P 1 .7
8
P 3 .0 /R X D
10
P 3 .1 /T X D
11
P 3 .2 /I NT 0
12
P 3 .3 /I NT 1
13
P 3 .4 /T 0
14
P 3 .7 /R D
17
P 3 .6 /W R
16
P 3 .5 /T 1
15
P 2 .7 /A 1 5
28
P 2 .0 /A 8
21
P 2 .1 /A 9
22
P 2 .2 /A 1 0
23
P 2 .3 /A 1 1
24
P 2 .4 /A 1 2
25
P 2 .5 /A 1 3
26
P 2 .6 /A 1 4
27
U1
A T 8 9 C5 1
NE T = D0 2
C3
1nF
R1
1 0 k
2
3
4
5
6
7
8
9
1
R P 1
RE S P A C K -8
L S 1
S P E A K E R
Q1
P N P
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
D1
L E D- R E D
D0
3
Q0
2
D1
4
Q1
5
D2
7
Q2
6
D3
8
Q3
9
D4
13
Q4
12
D5
14
Q5
15
D6
17
Q6
16
D7
18
Q7
19
OE
1
LE
11
U3
7 4 L S 3 7 3
D0
3
Q0
2
D1
4
Q1
5
D2
7
Q2
6
D3
8
Q3
9
D4
13
Q4
12
D5
14
Q5
15
D6
17
Q6
16
D7
18
Q7
19
OE
1
LE
11
U2
7 4 L S 3 7 3
DU L A
W E L A
DU L A
W E L A
p 1 1
p 1 1
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!