【正文】
音樂播放按鍵切換到下一首歌曲開始播放,最后再次點(diǎn)擊音樂播放按鍵退出音樂播放界面。它的一個(gè)工作周期可分為兩個(gè)部分,即溫度檢測盒數(shù)據(jù)處理。I/O為串行數(shù)據(jù)輸入輸出端(雙向),SCLK始終是輸入端。晶振電路由兩個(gè)33pF的電容和一個(gè)12MHZ晶體振蕩器構(gòu)成,晶體振蕩器兩端分別接入單片機(jī)的XTALXTAL2引腳。另外通過DS18B20溫度傳感器通過檢測環(huán)境溫度在LCD上顯示出來。 溫度模塊方案方案一:采用DS18B20溫度芯片。方案二:采用LED數(shù)碼管動態(tài)掃描。2系統(tǒng)方案分析與選擇論證方案一:采用STC89C52單片機(jī)作為主控芯片。數(shù)字鐘用集成電路計(jì)時(shí),譯碼代替機(jī)械式傳動,用LCD顯示器代替指針進(jìn)而顯示時(shí)間,減小了計(jì)時(shí)誤差,這種表具有顯示時(shí)、分、秒時(shí)間的功能,還可以進(jìn)行時(shí)和分的校對,片選的靈活性好。隨著單片機(jī)技術(shù)的飛速發(fā)展,在其推動下,現(xiàn)代的電子產(chǎn)品幾乎滲透到了社會的各個(gè)領(lǐng)域,人們對時(shí)間計(jì)量的精度要求越來越高,應(yīng)用越來越廣。本文所闡述的數(shù)字鐘有多種功能,不僅能夠準(zhǔn)確的顯示時(shí)間年月日、時(shí)分秒,還有對環(huán)境溫度進(jìn)行測量,鬧鐘設(shè)置,秒表計(jì)時(shí),電子鐘, MP3播放等功能。時(shí)間與人們的生活息息相關(guān),而時(shí)間的計(jì)算方法發(fā)展至今已經(jīng)演變成時(shí)鐘和表。t care too much, in a variety of daily life and all kinds of social activities, we every hour and moment are watching the change of time. The time of our lives, and the calculation method of time has evolved into a clock and watch. Digital clock is described in this paper has a variety of functions, not only can display the date when the minutes and seconds time, accurate, and measurement of environmental temperature, alarm clock, stopwatch, electronic clock, MP3 player and other functions. Compared to the mechanical clock, because the digital clock is used in the digital circuit technology to realize, when, seconds, has a higher accuracy and stability, and the structure and device of digital clock is more scientific and convenient.This paper mainly introduces the design of multifunction digital clock based on MCU, the hardware circuit consists of the clock module, temperature detecting module, liquid crystal display module, keyboard module, power module, voice module and a reset circuit, software design including alarm clock, stopwatch design, electronic book reading, MP3 player etc.. The design of the digital clock: time date display, minutes and seconds, alarm clock, stopwatch, ebooks, MP3 etc.. Combined with the MCU and the multifunction digital clock, not only makes the measurement more accurate and stable time, environmental testing temperature is more simple, convenient, flexible, provides better quality and convenience to our daily life. Therefore, the single chip not only promoted the development of social productive forces and the improvement of social informationbased degree, simultaneously also makes the modern electronic products to further improve the performance.Key words: SCM digital clock the temperature sensor目 錄1 前言 1 課題的研究背景 1 課題的開發(fā)目的 12系統(tǒng)方案分析與選擇論證 2 2 2 顯示模塊方案 2 鍵盤模塊方案 2 溫度模塊方案 2 系統(tǒng)最終方案 33硬件電路設(shè)計(jì) 3 單片機(jī)最小系統(tǒng) 3 DS1302時(shí)鐘模塊的設(shè)計(jì) 4 LCD1602顯示模塊的設(shè)計(jì) 5 DS18B20溫度模塊的設(shè)計(jì) 7 聲音模塊和按鍵控制模塊的設(shè)計(jì) 74 程序設(shè)計(jì) 8 時(shí)間調(diào)整程序設(shè)計(jì) 9 鬧鐘處理程序設(shè)計(jì) 10 秒表計(jì)時(shí)程序設(shè)計(jì) 10 音樂播放程序設(shè)計(jì) 10 電子書程序設(shè)計(jì) 125調(diào)試與調(diào)試結(jié)果 12 硬件調(diào)試 12 調(diào)試結(jié)果 136 結(jié)論 13參考文獻(xiàn) 14附錄A 電路原理圖 15附錄B設(shè)計(jì)程序 16致謝 62華南農(nóng)業(yè)大學(xué)本科生畢業(yè)設(shè)計(jì)成績評定表621 前言 課題的研究背景在這個(gè)快節(jié)奏的年代,時(shí)間就是效益,就是金錢,因此準(zhǔn)確的掌握時(shí)間和分配時(shí)間對人們來說至關(guān)重要。數(shù)字鐘是一種數(shù)字電路,由于采用了石英技術(shù),因此走時(shí)精度高,穩(wěn)定性好,使用方便,不需要經(jīng)常調(diào)校。本設(shè)計(jì)相比傳統(tǒng)時(shí)鐘,不僅測量精確到高,工作穩(wěn)定,而且功能多也便于日后擴(kuò)展,在日常生活中具有很高的使用價(jià)值。液晶顯示屏的顯示功能強(qiáng)大,可顯示大量文字,顯示多樣,清晰可見,燈光柔和,可調(diào)范圍大,且價(jià)格適中。經(jīng)過兩種方案比較,選擇方案一。按鍵控制模塊DS1302時(shí)鐘模塊STC89C52LCD1602顯示模塊聲音模塊(喇叭)DS18B20溫度模塊電源模塊復(fù)位電路圖1 系統(tǒng)框圖如圖1所示,系統(tǒng)的整個(gè)控制流程是:經(jīng)過程序編程,向DS1302中寫入一個(gè)初值,如寫入2013327 23:56:58 WED,便從此開始計(jì)時(shí)。只要Vcc的上升時(shí)間不超過1ms,就可以實(shí)現(xiàn)自動上電復(fù)位。如果在傳送過程中RST置為低電平,則會終止此次數(shù)據(jù)傳送,I/O引腳變?yōu)楦咦钁B(tài)。DS18B20的測量范圍為55℃~+125℃,℃,可在1s(典型值)內(nèi)把溫度變換成數(shù)字,它的工作電源為:3~5V/DC,可選擇寄生工作方式,是一種先進(jìn)的單總線數(shù)據(jù)通信方式。點(diǎn)擊電子書按鍵,進(jìn)入電子書閱覽界面,點(diǎn)擊上調(diào)按鍵向上翻頁,點(diǎn)擊下調(diào)按鍵向下翻頁,最后點(diǎn)擊電子書按鍵退出電子書閱覽界面。圖7為時(shí)間調(diào)整程序流程圖。圖9為秒表計(jì)時(shí)程序流程圖。首要檢查的電源的正負(fù)極有沒有接反以及電源之間有沒有短路,各電源之間需要共VCC并且所有的地線需要共地。其次調(diào)試溫度測量模塊,保證DS18B20供電正常,然后調(diào)試保證DS1302供電正常,最后開始調(diào)試各按鍵模塊的功能。uchar code tabe3[]=Alarm set:。 uchar code LengthTab[7]= { 1,2,4,8,16,32,64 }。 //ds18b20溫度傳送數(shù)據(jù)IO口sbit ds1302_rst = P1^2。 //選擇按鍵 sbit up = P1^6。sbit ACC7=ACC^7。z) for(y=110。 ds18b20_delay(8)。 for(i=8。 ds18b20_delay(1)。 DQ=1。 ds18b20_init()。 b=read_onechar()。k0。k) { ACC7=ds1302_io。 write_byte(add)。 write_byte(add)。 //寫允許 ds1302_write(0x80,0x58)。 //寫保護(hù) }/***************************lcd1602***************************/void lcd_write_(uchar ) //命令字寫入lcd單元中{ lcd1602_rw=0。 lcd1602_e=0。 lcd1602_e=1。}void lcd1602_init() //LCD初始化函數(shù) { uchar lcdnum。lcdnum8。 }}/****************************顯示部分*****************************/void write_time1(uchar add,uchar date) //日期送顯示{ uchar shi,ge。 ge=date%10。 return decimal。 //取十位 temp除不用定義類型 wendu_ge =((uint)temp)%100/10。 lcd_write_date(0xdf)。)。 lcd_write_date(39。W39。 break。U39。)。 lcd_write_date(39。S39。 break。 alarm_out=~alarm_out。 if(shi23) shi=0。 case 6: yue++。 //減 更新標(biāo)志 while(!down)。 if(miao==255) shi=23。 case 6: yue。 fen==alarm_fen amp。j++) alarm_out=~alarm_out。 alarm_out=1。 } lcd_write_(0x0f)。O39。 } if(alarm_on==1) { lcd_write_(0x80+0x40+13)。N39。 delay(2)。 for(num=0。num14。amp。 //按set一下,count加1 if(flag==1) { done=1。amp。 if(nao==0) { while(!nao)。amp。 if(miaobiao==0) { while(!miaobiao)。amp。 if(book==0) { while(!book)。amp。 if(music==0) { while(!music)。 key_up_down()。 //液晶寫字符后光標(biāo)自動向右移動一位,把光標(biāo)左移一位 } } while(count==2)。 ds1302_write(0x8e,0x80)。 flag_down=0。 case 4: do { lcd_write_(0x80+0x0e)。 lcd_write_(0x80+0x0e)。 ds1302_write(0x86,key_bcd(ri))。 if(flag_up || flag_down) { flag_up=0。 break。 write_time1(2,nian)。 ds1302_write(0x80,key_bcd(miao)amp。 alarm_on=1。 lcd_write_date(39。 lcd_write_(0x80+0x40+13)。F39。 alarm_miao++。 } break。 if(alarm_fen==255) alarm_fen=59。 alarm_shi++。 } break。 watch_flag=1。 case 2: miaobiao_count=0。 } } if(book_count!=0) { switch(book_count) { case 1: if(up==0) { delay(2)。 } } } b