#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar temp;
void delay(uint);
void main()
{
temp=0xfe;
P1=temp;
while(1)
{
delay(500);
temp=_crol_(temp,1);
P1=temp;
}
}
void delay (uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}这是第一个,下面还有
填了一个数码管的之后就产生不了效果了
这是合起来的效果的程序
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
uchar aa,num,temp;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x6f,0x7f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint);
void main()
{ num=0;
aa=0;
TMOD=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
temp=0xfe;
P1=temp;
wela=1;
P0=0xc0;
wela=0;
dula=1;
P0=table[0];
dula=0;
while(1)
{
delay(500);
temp=_crol_(temp,1);
P1=temp;
if(aa==40)
{ num++;
aa=0;
if(num==16)
num=0;
dula=1;
P0=table[num];
dula=0;
}
}
}
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void time() interrupt 3
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
}
这个程序到底哪儿错了
|