資源描述:
《51單片機(jī)c語言電子鐘》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、51單片機(jī)c語言電子鐘(已加入調(diào)時(shí)、鬧鈴、整點(diǎn)報(bào)時(shí)功能)效果圖:istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture程序如下://51
2、單片機(jī)c語言電子鐘(已加入調(diào)時(shí)、鬧鈴、整點(diǎn)報(bào)時(shí)功能)//WHJWNAVY2011/10/14?#include#include#defineucharunsignedchar#defineuintunsignedint/*七段共陰管顯示定義*///此表為L(zhǎng)ED的字模,共陰數(shù)碼管0-9?-ucharcodedispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};?//段碼控制/*定義并初始化變量*/ucharseconde=0;//秒ucharminite=0;//
3、分ucharhour=12;//時(shí)ucharmstcnt=0;//定時(shí)器計(jì)數(shù),定時(shí)50ms,mstcnt滿20,秒加1ucharshi=0;//鬧鈴功能ucharfen=0;ucharbjcs;//報(bào)警次數(shù)sbitP1_0=P1^0;????????????????//second調(diào)整定義sbitP1_1=P1^1;????????????????//minite調(diào)整定義sbitP1_2=P1^2;????????????????//hour調(diào)整定義sbitP1_5=P1^5;?????//整點(diǎn)報(bào)時(shí)sbitP1_3=P1^3;?????//鬧鈴功能,調(diào)整時(shí)間sbitP1_6=P1
4、^6;?????//調(diào)整時(shí)sbitP1_7=P1^7;?????//調(diào)整分sbitP1_4=P1^4;?????//關(guān)閉鬧鈴/*函數(shù)聲明*/voiddelay(uintk);?//延時(shí)子程序voidtime_pro();?????//時(shí)間處理子程序voiddisplay();??????//顯示子程序voidkeyscan();??????//鍵盤掃描子程序/*延時(shí)子程序*/voiddelay(uintk){ucharj;while((k--)!=0)??{istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemill
5、ion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture???for(j=0;j<125;j++)????{;}??}}?/*時(shí)間處理子程序*/voidtime_pro(void){?if(seconde==60)?{??seconde=0;??minite++
6、;??if(minite==60)??{???minite=0;???hour++;???if(hour==24)???{????hour=0;???}??}?}}/*顯示子程序*/voiddisplay(void){?if(P1_3==1)?{?P2=0XFE;?P0=dispcode[seconde%10];//秒個(gè)位?delay(1);?P2=0XFD;?P0=dispcode[seconde/10];//秒十位?delay(1);?P2=0XFB;?P0=dispcode[10];//間隔符-?delay(1);?P2=0XF7;?P0=dispcode[minite%1
7、0];//分個(gè)位?delay(1);?P2=0XEF;?P0=dispcode[minite/10];//分十位?delay(1);?P2=0XDF;istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,a