#include<intrins.h>
#define uchar unsigned char
uchar distab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00} //0到f
uchar number,dat,time
void t0isr() interrupt 1
{
TH0=(65536-5000)/256
TL0=(65536-5000)%256
number++
if(number>1)number=0
switch(number)
{
case 0:P2=0x02P0=distab[dat/10]
break
case 1:P2=0x01P0=distab[dat%10]
break
default:break
}
}
void t1isr() interrupt 3
{
TH1=(65536-50000)/256
TL1=(65536-50000)%256
time++
if(time%2)P1=_crol_(P1,1)
if(time%4)dat++
dat%=100
}
main()
{
TMOD=0x11
TH0=(65536-5000)/256
TL0=(65536-5000)%256
TH1=(65536-50000)/256
TL1=(65536-50000)%256
time=0
dat=0
TR1=1
ET1=1
TR0=1
ET0=1
EA=1
P1=0xfe
while(1)
}
#include //51系列单片机定义文件#define uchar unsigned char //定义无符号字符
#define uint unsigned int //定义无符号整数
void delay(uint)//声明延时函数
void main(void)
{
uint i
uchar temp
while(1)
{
temp=0xFE
for(i=0i<8i++) //8个流水灯依次全部点亮
{
P1=temp
delay(500)//调用延时函数
temp<<=1
}
}} void delay(uint t) //定义延时函数
{
register uint bt
for(tt--)
for(bt=0bt<255bt++)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)