单片机 定时器 中断 数码管 流水灯
题目:利用动态扫描和定时器1在数码管上显示出从765432开始以1/10秒的速度往下递减直至765398并保持显示此数,与此同时利用定时器0以500MS速度进行流水灯从上至下移动,当数码管上数减到停止时,实验板上流水灯也停止然后全部开始闪烁,3秒后(用T0定时)流水灯全部关闭、数码管上显示出“HELLO”。到此保持住。
程序:
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp,swan,wan,qian,ba,sh,g,bai,shi,ge,t,t1,m,i,f,w,t0;
uint aa;
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp,swan,wan,qian,ba,sh,g,bai,shi,ge,t,t1,m,i,f,w,t0;
uint aa;
uchar book[6]={7,6,5};
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0x76,0x79,0x38,0x38,0x3f,0};
uchar code guo[]={16,17,18,19,20,22};
unsigned char code seg[]={0,1,2,3,4,5,6,7};
void sor()
重阳节的传说简短50字{ aa=432;
EA=1;
ET0=1;
ET1=1;
TMOD=0x11;
TR0=1;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0x76,0x79,0x38,0x38,0x3f,0};
uchar code guo[]={16,17,18,19,20,22};
unsigned char code seg[]={0,1,2,3,4,5,6,7};
void sor()
重阳节的传说简短50字{ aa=432;
EA=1;
ET0=1;
ET1=1;
TMOD=0x11;
TR0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR1=1;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
}
void delay(uint z)一丘之貉是什么意思
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(void)
{
while(1)
TL0=(65536-50000)%256;
TR1=1;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
}
void delay(uint z)一丘之貉是什么意思
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(void)
{
while(1)
{
if(w!=1)什么风凛冽
m=book[i];
else m=guo[i];
P0=table
if(w!=1)什么风凛冽
m=book[i];
else m=guo[i];
P0=table
;//取显示数据,段码
P2=seg[i]; //取位码
delay(1); //扫描隙延时,时间太长会闪烁,太短会造成重影,这里使用长时间方便了解显示原理
i++;
if(6==i) //检测8位扫描完全?
i=0;
}
}
P2=seg[i]; //取位码
delay(1); //扫描隙延时,时间太长会闪烁,太短会造成重影,这里使用长时间方便了解显示原理
i++;
if(6==i) //检测8位扫描完全?
i=0;
}
}
void main()
{
sor();
temp=0xfe;
P1=temp;
while(1)
{
display();
}
{
sor();
temp=0xfe;
P1=temp;
while(1)
{
display();
}
}
void time0() interrupt 1
{
if(f!=1)
{TH0=(65536-50000)/256;
void time0() interrupt 1
{
if(f!=1)
{TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t++;
if(t==10)
{
t=1;
temp=_crol_(temp,1);
志同道合是什么意思 P1=temp;
}
}
else if(t0<=60)
P1=~P1;吃红心火龙果的禁忌
}
void timer1() interrupt 3
t++;
if(t==10)
{
t=1;
temp=_crol_(temp,1);
志同道合是什么意思 P1=temp;
}
}
else if(t0<=60)
P1=~P1;吃红心火龙果的禁忌
}
void timer1() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
t1++;
if(t1==2)
{
t1=0;
book[3]=aa/100;
book[4]=aa%100/10;
book[5]=aa%10;
if(aa>398) aa--;
else
{f=1;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
t1++;
if(t1==2)
{
t1=0;
book[3]=aa/100;
book[4]=aa%100/10;
book[5]=aa%10;
if(aa>398) aa--;
else
{f=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t=0;
t0++;
if(t0>60)反义词的成语
{TR0=0;
TR1=0;
w=1;
}
// while(1);
}
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论