版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、#include#include#define uint unsigned int#define uchar unsigned char#define lcd_bus P0sbit rs=P20;sbit rw=P21;sbit e=P22;sbit beep=P36;/蜂鳴器sbit DQ=P24;/DS18B20sbit SCL=P25;/AT24C16A sbit SDA=P26;/*鍵盤*sbit sw0=P30;sbit sw1=P31;sbit sw2=P32;sbit sw3=P33;sbit sw4=P34;sbit sw5=P35;sbit fan=P10;/風(fēng)扇sbit r
2、est=P11;sbit sclk=P12;/DS1302口定義sbit sdata=P13;uchar year=6,month=7,date=0x15,week=5,hour=0x10,minute=0x13,second=0; uchar hour,haomi,mi,sh,fe,swa,sec,min,hou; uchar code hanzi=0x00,0x0e,0x15,0x15,0x17,0x11,0x0e,0x00, 0x00,0x06,0x09,0x1d,0x09,0x01,0x06,0x00, 0x18,0x18,0x07,0x08,0x08,0x08,0x07,0x00,
3、0x01,0x03,0x1d,0x15,0x15,0x1d,0x03,0x01, 0x0e,0x11,0x0e,0x04,0x07,0x04,0x07,0x04; uchar code str_ok=OK;uchar code str_welcome1=Welcome to CAEP Inst;uchar code str_welcome2=itute of Technology!;uchar code str_timeup= TIME UP!;uchar code str_test=NNU ;uchar code str_su=Successful;uchar code str_menu1=
4、1.State;uchar code str_menu2=2.Setting;uchar code str_menu3=3.About;/uchar code str_time1= 2005/07/14 MON;/初始化DS1302uchar code str_time2= 19:30:59 ; uchar code str_time=Time ;uchar code str_date=Date ;uchar code str_swa=stopwatch;/秒表uchar code str_exit=-;uchar code str_alarm=Alarm ;uchar code str_al
5、arm2=Set Alarm;uchar code str_alarm3=Remove Alarm;uchar code str_beep1=Buzzer ;uchar code str_beep2=Close Buzzer;uchar code str_beep3=Open Buzzer;uchar code str_tem= Temperature;uchar code str_week=SUNMONTUSWENTHEFRISAT;uchar code str_v1=A :+12.4V 1.00A;uchar code str_v2=B :-12.4V 1.50A;uchar code s
6、tr_v3=C :+ 5.0V 1.00A;uchar code str_v4=D :- 5.0V 1.00A;uchar code str_am=AM Alarm;uchar code str_pm=PM Alarm; uchar state=0;bit alarm_f=0; /鬧鐘標(biāo)志位bit beep_f=1;/beep_f=0表示按鍵是蜂鳴器會響,beep_f=1表示按鍵是蜂鳴器不會響 uchar alarm_hour2,alarm_minute2,f=1,key_lock=0;bit ap=0;/ap=0設(shè)置上午鬧鐘, ap=1設(shè)置下午鬧鐘,/set_t為風(fēng)扇開啟的上限溫度,當(dāng)測得的
7、溫度大于set_t時(shí),風(fēng)扇啟動(dòng) unsigned char set_t; bit f_p=1;/*子函數(shù)的聲明*delay(uchar d);bit lcd_busy(void);/lcd忙標(biāo)志void lcd_wrcmd(uchar cmd);/寫LCD命令void lcd_wrdata(uchar lcddata);/寫lcd數(shù)據(jù)void lcd_ini(void);/初始化LCDvoid display(uchar cmd,uchar code *str);/lcd顯示位置確定uchar key();welcome();menu();time();lcd_h();clock();sett
8、ing_date();setting_time();voltage1();voltage2();uchar adconvert();alarm();set_alarm();about();rollscreen_l(uchar *str,uchar l);rollscreen_r(uchar *str,uchar l);time_up();close_beep();temp();stopwatch();/秒表void sent_char(uchar sentchar);uchar get_char();void set_wp_off();void set_wp_on();void set_tim
9、e();void read_time();am_pm();/*END*#include#include/*DS1302程序包*void sent_char(unsigned char sentchar) unsigned char ii; for(ii=0;ii1; unsigned char get_char()unsigned char getchar,ii,temp;getchar=0;temp=1;for(ii=0;ii8;ii+) sclk=0; sdata=1; if(sdata=1) getchar=getchar |temp; sclk=1; temp=temp23) hour
10、_temp=0;hour_h=hour_temp/10; hour_l=hour_temp%10; lcd_wrcmd(0x84); lcd_wrdata(0x30+hour_h); lcd_wrdata(0x30+hour_l);lcd_wrcmd(0x85);else if(ss=2)/ss=2為校min狀態(tài) minute_temp+;if(minute_temp59) minute_temp=0;minute_h=minute_temp/10; minute_l=minute_temp%10; lcd_wrcmd(0x87); lcd_wrdata(0x30+minute_h); lcd
11、_wrdata(0x30+minute_l);lcd_wrcmd(0x88); else if(ii=2)/sw5=減1操作 if(ss=1)/ss=1為校hour狀態(tài) hour_temp-;if(hour_temp=0xff) hour_temp=23;hour_h=hour_temp/10; hour_l=hour_temp%10; lcd_wrcmd(0x84); lcd_wrdata(0x30+hour_h); lcd_wrdata(0x30+hour_l);lcd_wrcmd(0x85);else if(ss=2)/ss=2為校min狀態(tài) minute_temp-;if(minute
12、_temp=0xff) minute_temp=59;minute_h=minute_temp/10; minute_l=minute_temp%10; lcd_wrcmd(0x87); lcd_wrdata(0x30+minute_h); lcd_wrdata(0x30+minute_l);lcd_wrcmd(0x88);else if(ii=5)/sw2=ready+menu+pause hour=hour_h*16+hour_l;minute=minute_h*16+minute_l;lcd_wrcmd(0x0c);set_time();lcd_wrcmd(1);display(0xc3
13、,str_su);/Successfulfor(n=0;n1500;n+)delay(250);lcd_wrcmd(1);state=2;break; else if(ii=6)/sw1=menu+ready+CLR lcd_wrcmd(1); lcd_wrcmd(0x0c); state=2;/clock(); break; /=setting_date=setting_date()/設(shè)置日期 uchar ii,ss=1;uint n;uchar year_h,year_l,month_h,month_l,date_h,date_l;uchar year_temp,month_temp,da
14、te_temp; lcd_wrcmd(1);year_h=year/16;year_l=year%16;date_h=date/16;date_l=date%16;month_h=month/16;month_l=month%16;year_temp=year_h*10+year_l;month_temp=month_h*10+month_l;date_temp=date_h*10+date_l;date_h=date/16;date_l=date%16;lcd_wrcmd(0x83);lcd_wrdata(2); lcd_wrdata(0);lcd_wrdata(0x30+year_h);l
15、cd_wrdata(0x30+year_l);lcd_wrdata(-);lcd_wrdata(month_h+0x30);lcd_wrdata(month_l+0x30);lcd_wrdata(-);lcd_wrdata(0x30+date_h);lcd_wrdata(0x30+date_l); lcd_wrcmd(0x8e);lcd_wrdata(str_week3*week-3);lcd_wrdata(str_week3*week-2);lcd_wrdata(str_week3*week-1);display(0xc0,str_ok);/OK display(0xce,str_exit)
16、;/99)year_temp=0; year_h=year_temp/10; year_l=year_temp%10; lcd_wrcmd(0x85); lcd_wrdata(0x30+year_h); lcd_wrdata(0x30+year_l); lcd_wrcmd(0x86); else if(ss=2) /Month add 1 month_temp+; if(month_temp12)month_temp=1; month_h=month_temp/10; month_l=month_temp%10; lcd_wrcmd(0x88); lcd_wrdata(0x30+month_h
17、); lcd_wrdata(0x30+month_l); lcd_wrcmd(0x89); else if(ss=3)/day add 1 date_temp+; if(date_temp31)date_temp=1; date_h=date_temp/10; date_l=date_temp%10; lcd_wrcmd(0x8b); lcd_wrdata(0x30+date_h); lcd_wrdata(0x30+date_l); lcd_wrcmd(0x8c); else if(ss=4)/week add 1 week+;if(week7)week=1;lcd_wrcmd(0x8e);l
18、cd_wrdata(str_week3*week-3);lcd_wrdata(str_week3*week-2);lcd_wrdata(str_week3*week-1);lcd_wrcmd(0x91); else if(ii=2) /sw5=Down-1 if(ss=1)/year Down-1 year_temp-; if(year_temp=0)year_temp=99; year_h=year_temp/10; year_l=year_temp%10; lcd_wrcmd(0x85); lcd_wrdata(0x30+year_h); lcd_wrdata(0x30+year_l);
19、lcd_wrcmd(0x86); else if(ss=2) /Month Down-1 month_temp-; if(month_temp=0)month_temp=12; month_h=month_temp/10; month_l=month_temp%10; lcd_wrcmd(0x88); lcd_wrdata(0x30+month_h); lcd_wrdata(0x30+month_l); lcd_wrcmd(0x89); else if(ss=3)/day Down-1 date_temp-; if(date_temp=0)date_temp=31; date_h=date_t
20、emp/10; date_l=date_temp%10; lcd_wrcmd(0x8b); lcd_wrdata(0x30+date_h); lcd_wrdata(0x30+date_l); lcd_wrcmd(0x8c);else if(ss=4)/week Down-1 week-;if(week1)week=7;lcd_wrcmd(0x8E);lcd_wrdata(str_week3*week-3);lcd_wrdata(str_week3*week-2);lcd_wrdata(str_week3*week-1);lcd_wrcmd(0x91); else if(ii=5) /sw2=O
21、K year=year_h*16+year_l; month=month_h*16+month_l;date=date_h*16+date_l;lcd_wrcmd(0x0c);set_time();lcd_wrcmd(1);display(0xc3,str_su);/Successfulfor(n=0;n); else if(ss=2) TR0=1; lcd_wrcmd(0x80);lcd_wrdata( ); lcd_wrdata( );lcd_wrcmd(0xc0); lcd_wrdata(-); lcd_wrdata(); else if(ii=1) /sw6=up ss+; if(ss
22、=3)ss=1;/ss=3=1 if(ss=1) lcd_wrcmd(0xc0); lcd_wrdata( ); lcd_wrdata( ); lcd_wrcmd(0x80); lcd_wrdata(-); lcd_wrdata(); else if(ss=2) lcd_wrcmd(0x80); lcd_wrdata( ); lcd_wrdata( ); lcd_wrcmd(0xc0); lcd_wrdata(-); lcd_wrdata(); else if(ii=5)/sw2=關(guān)閉秒表 if(ss=2) TR0=0; break; else if(ss=1) TR0=0; break; e
23、lse if(ii=6)/sw1=CLR+menu+ready TR0=0;fe=0; mi=0;sh=0;haomi=0;hour=0;min=0;sec=0;swa=0; write_down(13,0);write_down(10,0);write_down(7,0); write_down(4,0); write_up(13,0);write_up(10,0);write_up(7,0); write_up(4,0); lcd_wrcmd(1);state=2; /clock();break; set_alarm()/設(shè)置鬧鐘 uchar ii,ss=1,hour_h,hour_l,m
24、inute_h,minute_l;uchar hour_temp,minute_temp;uint n;if(ap=0) hour_h=alarm_hour0/10; hour_l=alarm_hour0%10; hour_temp=alarm_hour0; minute_h=alarm_minute0/10; minute_l=alarm_minute0%10; minute_temp=alarm_minute0;else hour_h=alarm_hour1/10; hour_l=alarm_hour1%10; hour_temp=alarm_hour1; minute_h=alarm_m
25、inute1/10; minute_l=alarm_minute1%10; minute_temp=alarm_minute1; lcd_wrcmd(1);lcd_wrcmd(0x84);lcd_wrdata(0x30+hour_h);lcd_wrdata(0x30+hour_l);lcd_wrdata(:);lcd_wrdata(0x30+minute_h);lcd_wrdata(0x30+minute_l);lcd_wrcmd(0x0f);display(0xc0,str_ok);/okdisplay(0xce,str_exit);/23) hour_temp=0;hour_h=hour_
26、temp/10; hour_l=hour_temp%10; lcd_wrcmd(0x84); lcd_wrdata(0x30+hour_h); lcd_wrdata(0x30+hour_l);lcd_wrcmd(0x85);else if(ss=2)/分鐘 minute_temp+;if(minute_temp59) minute_temp=0;minute_h=minute_temp/10; minute_l=minute_temp%10; lcd_wrcmd(0x87); lcd_wrdata(0x30+minute_h); lcd_wrdata(0x30+minute_l);lcd_wr
27、cmd(0x88); else if(ii=2)/sw5=down-1操作 if(ss=1) hour_temp-;if(hour_temp=0xff) hour_temp=23;hour_h=hour_temp/10; hour_l=hour_temp%10; lcd_wrcmd(0x84); lcd_wrdata(0x30+hour_h); lcd_wrdata(0x30+hour_l);lcd_wrcmd(0x85);else if(ss=2) minute_temp-;if(minute_temp=0xff) minute_temp=59;minute_h=minute_temp/10; minute_l=minute_temp%10; lcd_wrcmd(0x87); lcd_wrdata(0x30+minute_h); lcd_wrdata(0x30+m
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 幼兒園防騙防拐演練
- 知榮辱課件教學(xué)課件
- 食品安全與健康相關(guān)
- 退行性脊椎病X線
- 酶促反應(yīng)原理臨床治療
- DB1304T 488-2024大麗花露地栽培技術(shù)規(guī)程
- 聰聰課件 教學(xué)課件
- 高溫燙傷應(yīng)急預(yù)案演練
- 肺全切術(shù)后護(hù)理查房
- 運(yùn)動(dòng)治療儀器及使用方法
- AR眼鏡簡介介紹
- 藝術(shù)與體育的研究報(bào)告
- 2024年宣傳片拍攝保密協(xié)議doc-(含多場合)
- 畢業(yè)設(shè)計(jì)自行車測速儀
- 親子鑒定報(bào)告樣本
- 心理健康的重要性課件
- 新HSK一至六級詞匯表
- 眼鏡店?duì)I業(yè)員工作總結(jié)
- 社區(qū)管理與服務(wù)創(chuàng)新課件
- 2024年度醫(yī)院皮膚科中醫(yī)帶教計(jì)劃課件
- 海鮮自助策劃方案
評論
0/150
提交評論