久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

密碼程序與計時程序的結合-基于51MCU-C語言

[復制鏈接]
跳轉到指定樓層
樓主
ID:76556 發表于 2015-4-10 03:01 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
啟動顯示  1602液晶示第一行顯示you win!第二行顯示I Iove 51MCU!
設定的密碼61513
輸入密碼時 1602液晶第一行顯示*號 (每按下一次鍵盤*號增加一個)
第一次密碼輸入錯誤后 1602液晶示第一行顯示Error!第二行顯示Call 13808197643
第二次密碼輸入錯誤后  程序自鎖只有重新啟動51單片機
密碼輸入正確后  1602液晶示第一行顯示My Name is第二行顯示Xue Yu Hao 之后延時一會兒(這里我沒有測試過到底延時多少秒)就進入計時程序秒記一次,可以計時1小時) 按下key6計時停止,

















{,,,,,C語言程序如下,,,,,,,}

#include<reg51.h>

#define uchar unsigned char
#define uint unsigned int
uchar code xian1[]="you win!";
uchar code xian2[]="I Iove 51MCU!";
uchar code good1[]="My Name is";
uchar code good2[]="Xue Yu Hao";
uchar code cuowu1[]="Error!";
uchar code cuowu2[]="Call 13808197643";
uchar code mimi[]="*";
uchar code shizhongdd[]="into the clock";
uchar code maohao[]=":";
uchar code ling[]="00";
uchar code shu0[]="0";
uchar code shu1[]="1";
uchar code shu2[]="2";
uchar code shu3[]="3";
uchar code shu4[]="4";
uchar code shu5[]="5";
uchar code shu6[]="6";
uchar code shu7[]="7";
uchar code shu8[]="8";
uchar code shu9[]="9";
uchar cc,mima0,mima1,mima2,mima3,mima4,mima5,mima6,mima7,mima1zy,num1,num2,num3,dsd1,dsd2,dsd3,fen1,fen2,fen3,fen4;
sbit rs=P1^0;
sbit rw=P1^1;
sbit e=P1^2;
sbit key0=P0^0;
sbit key1=P0^1;
sbit key2=P0^2;
sbit key3=P0^3;
sbit key4=P0^4;
sbit key5=P0^5;
sbit key6=P0^6;
sbit key7=P0^7;
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 jianpan()
{
if(key0==0)
        {
        timer(5);
        if(key0==0)
                {
                mima0=1;
                num1++;
                while(!key0);
                }
        }
if(key1==0)
        {
        timer(5);
        if(key1==0)
                {
                mima1=1;
                num1++;
                mima1zy++;
                while(!key1);
                }
        }
if(key2==0)
        {
        timer(5);
        if(key2==0)
                {
                mima2=1;
                num1++;
                while(!key2);
                }
        }
if(key3==0)
        {
        timer(5);
        if(key3==0)
                {
                mima3=1;
                num1++;
                while(!key3);
                }
        }
if(key4==0)
        {
        timer(5);
        if(key4==0)
                {
                mima4=1;
                num1++;
                while(!key4);
                }
        }
if(key5==0)
        {
        timer(5);
        if(key5==0)
                {
                mima5=1;
                num1++;
                while(!key5);
                }
        }
if(key6==0)
        {
        timer(5);
        if(key6==0)
                {
                mima6=1;
                num1++;
                while(!key6);
                }
        }
if(key7==0)
        {
        timer(5);
        if(key0==0)
                {
                mima7=1;
                num1++;
                while(!key0);
                }
        }

}
void xianshide()
{
init();
zhiling(0x80);
for(cc=0;cc<10;cc++)
        {
        shuju(good1[cc]);
        timer(5);
        }
zhiling(0x80+0x43);
for(cc=0;cc<10;cc++)
        {
        shuju(good2[cc]);
        timer(5);
        }
}
void cuowude()
{
num1=0;
init();
zhiling(0x80+0x05);
if(num3==0)
                {
        for(cc=0;cc<5;cc++)
                {
                shuju(cuowu1[cc]);
                timer(5);
                }
        zhiling(0x80+0x40);
        for(cc=0;cc<16;cc++)
                {
                shuju(cuowu2[cc]);
                timer(5);
                }
        num3=1;
        }
}
void mimide()
{
if(num1==1)
        {
        init();
        zhiling(0x80);
        for(cc=0;cc<1;cc++)
                {
                shuju(mimi[cc]);
                timer(5);
                }
        }
if(num1==2)
        {
        zhiling(0x80+0x01);
        for(cc=0;cc<1;cc++)
                {
                shuju(mimi[cc]);
                timer(5);
                }
        }
if(num1==3)
        {
        zhiling(0x80+0x02);
        for(cc=0;cc<1;cc++)
                {
                shuju(mimi[cc]);
                timer(5);
                }
        }
if(num1==4)      
        {
        zhiling(0x80+0x03);
        for(cc=0;cc<1;cc++)
                {
                shuju(mimi[cc]);
                timer(5);
                }
        }
if(num1==5)      
        {
        zhiling(0x80+0x04);
        for(cc=0;cc<1;cc++)
                {
                shuju(mimi[cc]);
                timer(5);
                }
        }
if(num1==6)      
        {
        zhiling(0x80+0x05);
        for(cc=0;cc<1;cc++)
                {
                shuju(mimi[cc]);
                timer(5);
                }
        }
if(num1==7)      
        {
        zhiling(0x80+0x06);
        for(cc=0;cc<1;cc++)
                {
                shuju(mimi[cc]);
                timer(5);
                }
        }
}
void gaibian()
{
EA=0;
while(1)
        {
        jianpan();
        if(mima0==1)
                {
                zhiling(0x0f);
                zhiling(0x80+0x46);
                dsd2++;
                mima0=0;
                }
        if(mima0==0)
                {
                zhiling(0x0c);
                }
        }
}
void laozhong()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
init();
zhiling(0x80);
for(cc=0;cc<14;cc++)
        {
        shuju(shizhongdd[cc]);
        timer(5);
        }
zhiling(0x80+0x44);
                for(cc=0;cc<1;cc++)
                        {
                        shuju(maohao[cc]);
                        timer(5);
                        }
zhiling(0x80+0x42);
                for(cc=0;cc<2;cc++)
                        {
                        shuju(ling[cc]);
                        timer(5);
                        }

while(1)
        {
        if(dsd2==0)
                {
                zhiling(0x80+0x46);
                for(cc=0;cc<1;cc++)
                        {
                        shuju(shu0[cc]);
                        timer(5);
                        }
                zhiling(0x80+0x45);
                for(cc=0;cc<1;cc++)
                        {
                        shuju(shu0[cc]);
                        timer(5);
                        }
               
                }
        if(dsd2==1)
                {
                zhiling(0x80+0x46);
                for(cc=0;cc<1;cc++)
                        {
                        shuju(shu1[cc]);
                        timer(5);
                        }
                }
        if(dsd2==2)
                        {
                        zhiling(0x80+0x46);
                        for(cc=0;cc<1;cc++)
                                {
                                shuju(shu2[cc]);
                                timer(5);
                                }
                        }
        if(dsd2==3)
                        {
                        zhiling(0x80+0x46);
                        for(cc=0;cc<1;cc++)
                                {
                                shuju(shu3[cc]);
                                timer(5);
                                }
                        }
        if(dsd2==4)
                        {
                        zhiling(0x80+0x46);
                        for(cc=0;cc<1;cc++)
                                {
                                shuju(shu4[cc]);
                                timer(5);
                                }
                        }
        if(dsd2==5)
                        {
                        zhiling(0x80+0x46);
                        for(cc=0;cc<1;cc++)
                                {
                                shuju(shu5[cc]);
                                timer(5);
                                }
                        }
        if(dsd2==6)
                        {
                        zhiling(0x80+0x46);
                        for(cc=0;cc<1;cc++)
                                {
                                shuju(shu6[cc]);
                                timer(5);
                                }
                        }
        if(dsd2==7)
                        {
                        zhiling(0x80+0x46);
                        for(cc=0;cc<1;cc++)
                                {
                                shuju(shu7[cc]);
                                timer(5);
                                }
                        }
        if(dsd2==8)
                        {
                        zhiling(0x80+0x46);
                        for(cc=0;cc<1;cc++)
                                {
                                shuju(shu8[cc]);
                                timer(5);
                                }
                        }
        if(dsd2==9)
                        {
                        zhiling(0x80+0x46);
                        for(cc=0;cc<1;cc++)
                                {
                                shuju(shu9[cc]);
                                timer(5);
                                }
                        }
                        if(dsd3==0)
                                {
                                zhiling(0x80+0x45);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu0[cc]);
                                        timer(5);
                                        }
                                }
                        if(dsd3==1)
                                {
                                zhiling(0x80+0x45);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu1[cc]);
                                        timer(5);
                                        }
                                }
                        if(dsd3==2)
                                {
                                zhiling(0x80+0x45);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu2[cc]);
                                        timer(5);
                                        }
                                }
                        if(dsd3==3)
                                {
                                zhiling(0x80+0x45);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu3[cc]);
                                        timer(5);
                                        }
                                }
                        if(dsd3==4)
                                {
                                zhiling(0x80+0x45);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu4[cc]);
                                        timer(5);
                                        }
                                }
                        if(dsd3==5)
                                {
                                zhiling(0x80+0x45);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu5[cc]);
                                        timer(5);
                                        }
                                }
                        if(dsd3==6)
                                {
                                zhiling(0x80+0x45);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu6[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==0)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu0[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==1)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu1[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==2)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu2[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==3)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu3[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==4)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu4[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==5)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu5[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==6)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu6[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==7)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu7[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==8)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu8[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen1==9)
                                {
                                zhiling(0x80+0x43);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu9[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen2==0)
                                {
                                zhiling(0x80+0x42);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu0[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen2==1)
                                {
                                zhiling(0x80+0x42);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu1[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen2==2)
                                {
                                zhiling(0x80+0x42);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu2[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen2==3)
                                {
                                zhiling(0x80+0x42);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu3[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen2==4)
                                {
                                zhiling(0x80+0x42);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu4[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen2==5)
                                {
                                zhiling(0x80+0x42);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu5[cc]);
                                        timer(5);
                                        }
                                }
                        if(fen2==6)
                                {
                                zhiling(0x80+0x42);
                                for(cc=0;cc<1;cc++)
                                        {
                                        shuju(shu6[cc]);
                                        timer(5);
                                        }
                                }
                        mima6=0;
if(key6==0)
        {
        timer(5);
        if(key6==0)
                {
                mima6=1;
                num1++;
                while(!key6);
                }
        }
                        while(mima6==1)
                                {

                                gaibian();

                                }
        }
}

void zhuchengxu()
{
num1=0;
while(1)
        {
        jianpan();
        while(mima6==1&num1==1)
                {
        mimide();
jianpan();
mima1zy=0;
                while(mima1==1&num1==2)
                        {
mimide();
jianpan();

                        while(mima5==1&num1==3)
                                {
mimide();
jianpan();
                                while(mima1==1&num1==4&mima1zy==1)
                                        {
mimide();
jianpan();

                                        while(mima3==1&num1==5)
                                                {mimide();
                                                xianshide();
mima3=0;
                                                num2=2;
                                                timer(2000);
                                                timer(2000);
                                                timer(2000);
                                                mima6=0;
                                                laozhong();
                                                }

                                        }

                                }

                        }

                }
mimide();
        if(num1==7)
                {
                if(num2!=2)
                        {
                        if(num3==0)
                                {
                        cuowude();
                        num1=0;
                        mima6=0;
                        mima1=0;
                        mima5=0;               
        mima3=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);
        }
while(1)
        {
        zhuchengxu();
        }
}
void dsq0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
dsd1++;
if(dsd1==20)     /////////////////////////這里did1==1是錯誤的因改為dsd1==20
        {
        dsd1=0;
        dsd2++;
        if(dsd2==10)
                {
                dsd2=0;
                dsd3++;
                if(dsd3==6)
                        {
                        dsd3=0;
                        fen1++;
                        if(fen1==10)
                                {
                                fen1=0;
                                fen2++;
                                if(fen2==6)
                                        {
                                                fen2=0;
                                        }
                                }
                        }
                }
        }
}





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

使用道具 舉報

沙發
ID:76556 發表于 2015-4-10 03:03 | 只看該作者
很復雜的程序  用了三天時間 應該說是寫了一天改了兩天
回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 中国美女撒尿txxxxx视频 | 欧美国产亚洲一区二区 | 国产一区二区在线观看视频 | 国产久| 91社影院在线观看 | 久久免费福利 | av国产精品毛片一区二区小说 | 国产成人午夜电影网 | 操人视频在线观看 | 亚洲欧美一区二区三区国产精品 | 日韩高清国产一区在线 | 夜夜骑首页 | 黄色在线免费观看 | 国产亚洲精品久久久优势 | 亚洲第一中文字幕 | 91精品国产综合久久婷婷香蕉 | 免费成人在线网 | 国产精品一区一区 | 日韩电影中文字幕在线观看 | 亚洲综合日韩精品欧美综合区 | 久久三区| 久草在线 | 亚洲精品一区二区三区蜜桃久 | 国内精品久久久久久久 | 久久久久久亚洲精品 | 成人av网站在线观看 | 在线视频一区二区 | 国产99热 | 国产成人精品久久 | 国产日韩一区二区三区 | 自拍偷拍一区二区三区 | 欧美性一区二区三区 | 人人干人人玩 | 午夜性色a√在线视频观看9 | 国产一区二区观看 | 国产小视频在线 | 欧美日韩在线播放 | 99re6在线| 看一级毛片视频 | www.日韩系列| 超碰地址|