#include<reg51.h>
#include<stdio.h>
#define uint unsigned int
sbit outled=P1;
sbit gndH=P2^4;
sbit gndL=P2^5;
sbit key1=P0^0;//out
sbit key2=P0^1;
sbit key3=P0^2;
sbit key4=P0^3;
sbit key5=P0^4;//in
sbit key6=P0^5;
sbit key7=P0^6;
sbit key8=P0^7;
bit clock;
bit BJ;
sbit fm=P3^7; //蜂鸣报警口,低电平有效
uint s;
uint t;
void Delay(uint x)
{
uint i;
TMOD=0x01;
TL0=(65536-45872)%256;
TH0=(65536-45872)/256;
TR0=1;
for(i=0;i<(x/50);)
{
if(TF0) i++;
}
clock=~clock;
}
/***void main()
{ int a=15;
P2=0x00;
while(1)
{
Delay(50000);
led3=a/8;
led2=a%8/4;
led1=a%4/2;
led0=a%2;
led1=~led1;
if(a<15) a++;
else a=0;
}
}***/
//**二进制转LED显示**/
uint EZL(uint a)
{
uint b;
switch(a)
{case 0x00: b=0x00;break;
case 0x01: b=0x28;break;
case 0x02: b=0xCD;break;
case 0x03: b=0x6D;break;
case 0x04: b=0x2E;break;
case 0x05: b=0x67;break;
case 0x06: b=0xE7;break;
case 0x08: b=0xEF;break;
case 0x09: b=0x6F;break;
default: b=0x00;break;
}
return b;
}
/***LED显示***/
void led8(uint a)
{
uint outled;
uint H,L;
H=a/10;
L=a%10;
if(clock==1)
{ outled=EZL(H);gndH=1;gndL=0;}
else {outled=EZL(L);gndH=0;gndL=1;}
}
/**蜂鸣器***/
void Fm()
{
if(BJ) fm=0;
}
/****键盘扫描***/
uint Sm( )
{
uint i=0,c,d,n=0;
uint a,b;
P0=0x00;
while(1)
{
Delay(20);
while(clock)
{
if(n==0) {n=1;key1=1;P0=0x01;}
else if(n==1) {n=2;key2=1;P0=0x02;}
else if(n==2) {n=3;key3=1;P0=0x04;}
else {n=0;key4=1;P0=0x08;}
switch(n)
{
case 1:a=1;if(key5) b=1;
else if(key6) b=2;
else if(key7) b=3;
else if(key8) b=4;
else b=0;break;
case 2:a=2;if(key5) b=1;
else if(key6) b=2;
else if(key7) b=3;
else if(key8) b=4;
else b=0;break;
case 3:a=3;if(key5) b=1;
else if(key6) b=2;
else if(key7) b=3;
else if(key8) b=4;
else b=0;break;
case 0:a=4;if(key5) b=1;
else if(key6) b=2;
else if(key7) b=3;
else if(key8) b=4;
else b=0;break;
default : n=0;break;
}
if(b!=0) i++;
else i=0;
if(b!=0) i++;
else i=0;
if(b!=0) i++;
else i=0;
if(b!=0) i++;
else i=0;
if(i>=5) {i=5;break;}
}
if(i==5) break;
}
c=10*a+b;
switch (c)
{
case 11: d=1;break;
case 12: d=2;break;
case 13: d=3;break;
case 14: d=4;break;
case 21: d=5;break;
case 22: d=6;break;
case 23: d=7;break;
case 24: d=8;break;
case 31: d=9;break;
case 32: d=0;break;
default: d=10;break;
}
return d;
}
void main()
{ uint a;
t=0;s=0;
IT0=1;
EX0=1;
EA=1;
while(1)
{
a=10*t+s;
Delay(100);
led8(a);
}
}
void ex0() interrupt0 /中断子程序
{
t=Sm();
s=Sm();
}
提示错误出在最后中断子程序处,实在是不明白 找不到错在哪 请各路大神帮忙 多谢~
附上系统提示出错处:
TEST1.C(179): error C132: 'interrupt0': not in formal parameter list
TEST1.C(179): error C141: syntax error near '{'
TEST1.C(180): error C244: 't': can't ini
tialize, bad type or class
TEST1.C(180): error C132: 't': not in formal parameter list
TEST1.C(181): error C244: 's': can't initialize, bad type or class
TEST1.C(181): error C132: 's': not in formal parameter list
TEST1.C(182): error C141: syntax error near '}'
感谢!解决了!
一周热门 更多>