就是用定时器1在数码管上显示765432以1/10秒的速度递减 到765398停住 与此同时用定时器0以500ms的速度让流水灯单灯移动,当数码显示管计数停止 实验板上流水灯也停止 然后全部闪烁3秒 流水灯全部关闭 数码管显示出HELLO!
#include <reg51.h>
sbit cs1=P2^0;
sbit cs2=P2^1;
char tishi;
xianshi();
char uuu; sbit aaa=P3^1;
sbit bbb=P3^2;
sbit ccc=P3^3;
code unsigned char table[]={0xf8,0x82,0x92};
code unsigned char table1[]={0xc0,0x9f,0xa4,0xb0,0x99,0x92,0x83,0xf8,0x80,0x98};
code unsigned char table2[]={0x89,0x86,0xc7,0xc7,0xc0};
void delay(char qa)
{
char ws,ed;
for(ws=0;ws<qa;ws++)
for(ed=0;ed<100;ed++);
}
void gg() interrupt 1//递减
{
char yh,bb,ss,gg;
int shu;
bb=shu/100;
ss=shu%100/10;
gg=shu/10;
shu=432;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR1=1;
yh++;
if(yh==2)
{
shu--;
cs2=0;
P0=0xfb;
cs2=1;
cs1=0;
P0=bb;
cs1=1;
delay(5);
cs1=0;
P0=0xff;
cs1=1;
cs2=0;
P0=0xfd;
cs2=1;
cs1=0;
P0=ss;
cs1=1;
delay(5);
cs1=0;
P0=0xff;
cs1=1;
cs2=0;
P0=0xfe;
cs2=1;
cs1=0;
P0=gg;
cs1=1;
delay(5);
cs1=0;
P0=0xff;
cs1=1;
}
if(shu==398)
{
TR0=0;
TR1=0;
}
}
void hhhh() interrupt 0//流水灯
{
char uuu,hua;
uuu=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
hua++;
if(hua==10)
{
hua=0;
P1=~uuu;
uuu<<=1;
}
}
xianshi()//数码7-5
{
char tg,rf;
tg=0xdf;
TR0=0;uuu=0xff;
for(rf=0;rf<3;rf++)
{
cs2=0;
P0=~tg;
cs2=1;
tg>>=1;
cs1=0;
P0=table[rf];
cs1=1;
delay(50);
cs1=0;
P0=0xff;
cs1=1;
}
}
shans()//闪烁
{
char jia;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
jia++;
if(jia==60)
{
P0=0xff;
P0=0x00;
tishi=1;
}
}
hello()//显示HELLO
{
char pl,dh;
pl=0x10;
for(dh=0;dh<5;dh++)
{
cs2=0;
P0=~pl;
cs2=1;
pl>>=1;
cs1=0;
P0=table2[dh];
cs1=1;
delay(5);
cs1=0;
P0=0xff;
cs1=1;
}
}
void main()
{
TMOD=0x11;
TMOD=0x66;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
TR1=1;
EA=1;
EX0=1;
EX1=1;
while(1)
{
xianshi();
shans();
if(tishi==1)
hello();
P1=0xff;
}
}
再求他的流程图!!