|
想要實(shí)現(xiàn)的內(nèi)容是二極管500ms循環(huán)亮,數(shù)碼管每2s變化一個(gè)數(shù)字。程序如下:#include<reg52.h>
#include<intrins.h>
#define unint unsigned int
#define unchar unsigned char
void delay(unint z);
unchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
unint temp,aa,num;
unchar ;
sbit dula=P2^6;
sbit wela=P2^7;
sbit p1=P1^4;
void main()
{
aa=0;
num=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
p1=0;
dula=1;
P0=0x3f;
dula=0;
wela=1;
P0=0x00;
wela=0;
temp=0x7f;
P0=temp;
while(1)
{
delay(1000);
temp=_cror_(temp,1);
P0=temp;
}
}
void delay(unint z)
{
unint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void time() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==40)
{ dula=1;
num++;
P0=table[num];
if(num==16)
num=0;
dula=0;
aa=0;
}
}
分開執(zhí)行沒問題,合到一起二極管就不能按順序執(zhí)行了。。真心求教!! |
|