資源簡介
單片機\51單片機數碼管顯示萬年歷proteus仿真.rar
代碼片段和文件信息
#include
unsigned?char?code?dispcode[]={0x3F0x060x5B0x4F0x660x6D0x7D0x070x7F0x6F0x40};//共陰極
unsigned?char?dispbitcode[]={0x000x210x420x630x840xA50xC60xE7};//管子的選擇
unsigned?char?dispbuf[8]={0010001021};???//16為顯示間斷號符
unsigned?char?dispbym[8]={12706002};
unsigned?char?dispbitcnt;
unsigned?char?second;
unsigned?char?minite;
unsigned?char?hour;
unsigned?char?day;
unsigned?char?month;
unsigned?char?yearh;
unsigned?char?yearl;
unsigned?int?tcnt;
unsigned?char?mstcnt;
unsigned?char?ij;
void?main(void)
{
?TMOD=0x02;????????????????????//設置模式為定時器T0的模式2?(8位自動重裝計數初值的計數值)????????
?TH0=0x06;?????????????????????//設置計數器初值,靠TH0存儲重裝的計數值X0=256-250=6
?TL0=0x06;
?TR0=1;????????????????//啟動T0
?ET0=1;????????????????//開啟定時器T0中斷允許
?EA=1;?????????????????//開啟中斷總控制
?yearh=20;
?yearl=6;
?month=7;
?day=21;
?hour=12;??????????????//初始值為12:00:00
?while(1)
?{
??if(P0_0==0)????????????????//掃描秒鐘按鈕
??{
???for(i=5;i>0;i--)????????????//按鈕抖動消除
???for(j=248;j>0;j--);???????//計時
???if(P0_0==0)
???{
????second++;
????if(second==60)
????{
?????second=0;
????}
????dispbuf[0]=second%10;
????dispbuf[1]=second/10;
????while(P0_0==0);
???}
??}
??if(P0_1==0)?????????????//掃描分鐘按鈕
??{
???for(i=5;i>0;i--)???????
???for(j=248;j>0;j--);
???if(P0_1==0)
???{
????minite++;
????if(minite==60)
????{
?????minite=0;
????}
????dispbuf[3]=minite%10;
????dispbuf[4]=minite/10;
????while(P0_1==0);
???}
??}
??if(P0_2==0)???????????//掃描時鐘按鈕
??{
???for(i=5;i>0;i--)
???for(j=248;j>0;j--);
???if(P0_2==0)
???{
????hour++;
????if(hour==24)
????{
?????hour=0;
????}
????dispbuf[6]=hour%10;
????dispbuf[7]=hour/10;
????while(P0_2==0);
???}
??}
?
??if(P0_3==0)
??{
???for(i=5;i>0;i--)
???for(j=248;j>0;j--);
???if(P0_3==0)
???{
????day++;
????if(month==2&&((yearl==0&&yearh%4==0)||(yearl!=0&&yearl%4==0))&&day==30)day=1;??
????else?if(month==2&&day==29)day=1;
????else?if((month==4||month==6||month==9||month==11)&&day==31)day=1;
????else?if(day==32)day=1;
????dispbym[0]=day%10;
????dispbym[1]=day/10;
????while(P0_3==0);
???}
??}
??if(P0_4==0)
??{
???for(i=5;i>0;i--)
???for(j=248;j>0;j--);
???if(P0_4==0)
???{
????month++;
????if(month==13)month=1;
????dispbym[2]=month%10;
????dispbym[3]=month/10;
????while(P0_4==0);
???}
??}
??if(P0_5==0)
??{
???for(i=5;i>0;i--)
???for(j=248;j>0;j--);
???if(P0_5==0)
???{
????yearl++;
????if(yearl==100)
????{
?????yearl=0;
?????yearh++;
?????if(yearh==100)yearh=20;
????}
????dispbym[4]=yearl%10;
????dispbym[5]=yearl/10;
????dispbym[6]=yearh%10;
????dispbym[7]=yearh/10;
????while(P0_5==0);
???}
??}
?}
}
void?t0(void)interrupt?1?using?0???//t0的中斷程序
{
?mstcnt++;
?if(mstcnt==8)????????????????????//8次250us為2ms即每隔2ms掃描一個數碼管
?{
??mstcnt=0;
??P1=dispcode[dispbuf[dispbitcnt]];
??P2=dispcode[dispbym[dispbitcnt]];
??P3=0xff;
??P3=dispbitcode[dispbitcnt];??????????//管子的選擇
??dispbitcnt++;????????????????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????12856??2006-09-19?20:16??map.LYT
?????文件???????1028??2007-09-24?07:49??map.PWI
?????文件???????4302??2006-07-21?21:15??萬年歷.c
?????文件???????4344??2006-09-12?20:24??萬年歷星期的算法.txt
?????文件??????10141??2006-09-20?19:53??src\src.LST
?????文件????????168??2006-10-16?10:51??src\src.plg
?????文件??????18929??2006-09-20?19:53??src\src.OBJ
?????文件???????5912??2006-09-20?19:53??src\src.c
?????文件????????967??2006-09-23?23:55??src\src_Opt.Bak
?????文件????????970??2006-10-16?10:51??src\src.Opt
?????文件??????16021??2006-09-20?19:53??src\src
?????文件???????1679??2006-09-14?19:18??src\src_Uv2.Bak
?????文件???????4302??2006-09-11?23:51??src\Text1.c
?????文件???????2055??2006-09-19?20:55??src\src.Uv2
?????文件?????????23??2006-09-20?19:53??src\src.lnp
?????文件??????16566??2006-09-20?19:53??src\src.M51
?????文件???????7772??2006-09-20?19:53??src\src.hex
?????文件???????8632??2006-09-12?00:20??src\Text1.LST
?????文件??????10366??2006-09-12?00:20??src\Text1.OBJ
?????文件????????178??2007-06-02?16:05??test\src\src.plg
?????文件???????4302??2006-09-12?11:46??test\src\Text1.c
?????文件???????8632??2006-09-12?11:46??test\src\Text1.LST
?????文件??????10366??2006-09-12?11:46??test\src\Text1.OBJ
?????文件?????????25??2006-09-12?11:46??test\src\src.lnp
?????文件??????11009??2006-09-12?11:46??test\src\src.M51
?????文件???????8550??2006-09-12?11:46??test\src\src
????.......??????2103??2006-09-12?12:58??test\src\src_Uv2.Bak
????.......???????971??2006-09-12?12:58??test\src\src_Opt.Bak
?????文件???????2136??2007-03-22?16:07??test\src\src.Uv2
?????文件????????987??2007-03-22?16:07??test\src\src.Opt
............此處省略9個文件信息
- 上一篇:CAD LISP24個源代碼
- 下一篇:五子棋C 源代碼
評論
共有 條評論