欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4719|回復: 0
打印 上一主題 下一主題
收起左側

倒計時程序 1602液晶從5~0倒計時6秒,到0時計時停止程序停止

[復制鏈接]
跳轉到指定樓層
樓主
ID:76556 發表于 2015-4-10 02:57 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式

倒計時程序初級——范列
#include<reg51.h>

#define uchar unsigned char
#define uint unsigned int
uchar code xian1[]="you win!";
uchar code xian2[]="I Iove You^-^";
uchar code tishi[]="into the clock";
uchar code ling[]="00";
uchar code shu1[]="1";
uchar code shu2[]="2";
uchar code shu3[]="3";
uchar code shu4[]="4";
uchar code shu5[]="5";
uchar code shu0[]="0";
uchar cc,num1,num2,num3,num4,num5,num6;
sbit rs=P1^0;
sbit rw=P1^1;
sbit e=P1^2;
void timer(uint s)
{
uint x,c;
for(x=s;x>0;x--)
        for(c=110;c>0;c--);
}
void zhiling(uchar p)
{

rs=0;
rw=0;
P2=p;
timer(5);
e=1;
timer(5);
e=0;
}
void shuju(uchar y)
{
rs=1;
rw=0;
P2=y;
timer(5);
e=1;
timer(5);
e=0;
}

void init()
{

zhiling(0x38);
zhiling(0x0c);
zhiling(0x06);
zhiling(0x01);
}

void djs()
{

ET1=1;
TR1=1;

}
void timerkai()
{
TMOD=0x11;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
ET1=0;
TR1=0;
num3=0;
num5=6;
num6=0;
}
void main()
{
init();
zhiling(0x80);
for(cc=0;cc<8;cc++)
        {
        shuju(xian1[cc]);
        timer(5);
        }
zhiling(0x80+0x42);
for(cc=0;cc<13;cc++)
        {
        shuju(xian2[cc]);
        timer(5);
        }
timerkai();
        while(1)
                {
                if(num2==5|num3==1)
                        {
                        num3=1;
                        djs();
                                init();
                                zhiling(0x80+0x01);
                                for(cc=0;cc<14;cc++)
                                        {
                                        shuju(tishi[cc]);
                                        timer(5);
                                        }
                                zhiling(0x80+0x48);
                                for(cc=0;cc<2;cc++)
                                        {
                                        shuju(ling[cc]);
                                        timer(5);
                                        }
                        while(1)
                                {
                                if(num5==1)
                                        {
                                        zhiling(0x80+0x49);
                                        for(cc=0;cc<1;cc++)
                                                {
                                                shuju(shu1[cc]);
                                                timer(5);
                                                }                                       
                                        }
                                if(num5==2)
                                        {
                                        zhiling(0x80+0x49);
                                        for(cc=0;cc<1;cc++)
                                                {
                                                shuju(shu2[cc]);
                                                timer(5);
                                                }                                       
                                        }
                                if(num5==3)
                                        {
                                        zhiling(0x80+0x49);
                                        for(cc=0;cc<1;cc++)
                                                {
                                                shuju(shu3[cc]);
                                                timer(5);
                                                }                                       
                                        }
                                if(num5==4)
                                        {
                                        zhiling(0x80+0x49);
                                        for(cc=0;cc<1;cc++)
                                                {
                                                shuju(shu4[cc]);
                                                timer(5);
                                                }                                       
                                        }
                                if(num5==5)
                                        {
                                        zhiling(0x80+0x49);
                                        for(cc=0;cc<1;cc++)
                                                {
                                                shuju(shu5[cc]);
                                                timer(5);
                                                }                                       
                                        }
                                if(num5==6)
                                        {
                                        zhiling(0x80+0x49);
                                        for(cc=0;cc<1;cc++)
                                                {
                                                shuju(shu0[cc]);
                                                timer(5);
                                                }                                       
                                        }
                                if(num6==1)
                                        {
                                       
                                        }
                                }
                        }
                }

}
void t0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
num1++;
        if(num1==20)
                {
                num2++;
                num1=0;
                if(num2==6)
                        {
                        num2=0;
                        }
                }
}
void t1() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
num4++;
if(num4==20)
        {
        num5--;
        num4=0;
        if(num5==0)
                {
                num5=6;
                TR1=0;
                ET1=0;
                num6=1;
                }
        }
}

設計者:薛羽豪


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表