久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

新聞中心

EEPW首頁 > 嵌入式系統 > 設計應用 > 我的電子鐘c程序完整代碼

我的電子鐘c程序完整代碼

作者: 時間:2016-11-29 來源:網絡 收藏
真的很感謝問問的朋友幫我解決了定時器的問題。

今天是拿到單片機的第五天了,經過五天的挑燈學習,單片機的基礎也算了解的三三兩兩了。

本文引用地址:http://cqxgywz.com/article/201611/323244.htm

解決了定時器問題,早上逃課,趁熱打鐵,把電子鐘的程序寫完。有一年沒有寫復雜的程序了,今天的過程也是磕磕碰碰,問題頗多。廢話不說了,想玩wow了。有圖有真相。

#include#define  unchar unsigned char//sbit beep=P1^5;unchar temp=0;unsigned char code shuzi[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};unsigned char  count[]={0,0,10,5,5,10,3,2};void delay(void){int i=100;while(--i);}unchar time(unchar j){if (temp==20){ temp=0 ;++count[0];if (count[0]==10){ count[0]=0;++count[1];}if(count[1]==6){count[1]=0;++count[3];}  if (count[3]==10){count[3]=0;++count[4];}if (count[4]==6){count[4]=0;++count[6];}if (count[6]==10){count[6]=0;++count[7];}if (count[7]==3)count[7]=0;if (count[7]==2&&count[6]==4)count[7]=count[6]=0;}return count[j];}void main(){unchar num,i,j;EA=1;ET0=1;TMOD=0x01;TL0=15535%256;TH0=15535/256;TR0=1;while(1){P2=0xff;i=1;for (j=0;j<8;++j){num=time(j);P2=P2-i;P0=shuzi[num];i=i*2;delay();}}}void  duan() interrupt 1{TL0=15535%256;TH0=15535/256;++temp;}


評論


技術專區

關閉