網(wǎng)絡(luò)消費網(wǎng) >  5G > > 正文
c51鬧鐘程序
時間:2022-02-09 18:22:04
左圖正面凹陷下去的是三個菜單按鈕,右圖邊上的usb接口是供程序下載的,內(nèi)部為四節(jié)鎳鎘電池供電電壓4.8v

#include#include#define uchar unsigned char#define uint unsigned intuchar hou=0,min=0,sec=0,houc=0,minc=0,secc=0;uint m=0;bit yy=0;sbit khou=P1^1;sbit kmin=P1^0;sbit timesea=P1^2;sbit clock=P3^7;sbit clear=P3^6;sbit input=P3^5;sbit mod=P0^0;sbit mac=P2^3;uchar codewela[]={0x7f,0xbf,0xef,0xdf};uchar code dula[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xD8,0x80,0x90};uchar data shu[4];uchar data cldat[4];void display();void clsan();void display1();void keycan();void disan();void keyc();void send(uchar dat);void send1(uchar dat1);void clocking();void playing();void delay(uint z){uint x,y;for(x=z;x>0;x--)for(y=12;y>0;y--);}void main(){TMOD=0x01;TH0=(65536-5000)/256;TL0=(65536-5000)%6;EA=1;ET0=1;TR0=1;while(1){if(!timesea)playing();else clocking();if((hou==houc)&(min==minc)&!timesea){mac=0;delay(1000);mac=1;mod=~mod;}else {mac=1;mod=1;}}}

void time0()interrupt1{TH0=(65536-5000)/256;TL0=(65536-5000)%6;m++;if(m==200){m=0;sec++;}if(sec==60){sec=0;min++;}if(min==60){min=0;hou++;}if(hou==24){hou=0;min=0;sec=0;}}void playing(){display();keycan();disan();}void display(){uchar a=4,k;while(a--){P2=0xff;if((m<100)&(a==1))k=0x80;else k=0x00;send(dula[shu[a]]-k);P2=wela[a];delay(2);clear=0;P2=0xff;clear=1;}}void disan(){shu[0]=hou/10;shu[1]=hou;shu[2]=min/10;shu[3]=min;

}void send(uchar dat){uchar a=8;while(a--){clock=0;input=0x80&dat;clock=1;dat<<=1;}}

void keycan(){if(kmin==0){mod=0;delay(10);while(kmin==0)display();mod=1;if(min>59)min=0;else min++;}

if(khou==0){mod=0;delay(50);while(khou==0)display();mod=1;if(hou>23)hou=0;else hou++;}

}void clocking(){keyc();clsan();clsan();display1();}void display1(){uchar d=4,k;while(d--){P2=0xff;if(d==1)k=0x80;else k=0x00;send1(dula[cldat[d]]-k);P2=wela[d];delay(2);clear=0;P2=0xff;clear=1;}}void keyc(){if(khou==0){mac=0;delay(50);mac=1;while(khou==0)display1();if(houc>23)houc=0;else houc++;}

if(kmin==0){mac=0;delay(50);mac=1;while(kmin==0)display1();if(minc>23)minc=0;else minc++;}

}void send1(uchar dat1){uchar a=8;while(a--){clock=0;input=0x80&dat1;clock=1;dat1<<=1;}}void clsan(){cldat[0]=houc/10;cldat[1]=houc;cldat[2]=minc/10;cldat[3]=minc;}

關(guān)鍵詞: c51鬧鐘程

版權(quán)聲明:
    凡注明來網(wǎng)絡(luò)消費網(wǎng)的作品,版權(quán)均屬網(wǎng)絡(luò)消費網(wǎng)所有,未經(jīng)授權(quán)不得轉(zhuǎn)載、摘編或利用其它方式使用上述作品。已經(jīng)本網(wǎng)授權(quán)使用作品的,應(yīng)在授權(quán)范圍內(nèi)使用,并注明"來源:網(wǎng)絡(luò)消費網(wǎng)"。違反上述聲明者,本網(wǎng)將追究其相關(guān)法律責任。
    除來源署名為網(wǎng)絡(luò)消費網(wǎng)稿件外,其他所轉(zhuǎn)載內(nèi)容之原創(chuàng)性、真實性、完整性、及時性本站不作任何保證或承諾,請讀者僅作參考并自行核實。
熱文

網(wǎng)站首頁 |網(wǎng)站簡介 | 關(guān)于我們 | 廣告業(yè)務(wù) | 投稿信箱
 

Copyright © 2000-2020 m.netfop.cn All Rights Reserved.
 

中國網(wǎng)絡(luò)消費網(wǎng) 版權(quán)所有 未經(jīng)書面授權(quán) 不得復(fù)制或建立鏡像
 

聯(lián)系郵箱:920 891 263@qq.com

備案號:京ICP備2022016840號-15

營業(yè)執(zhí)照公示信息