资源简介
C51的数字时钟.rar
代码片段和文件信息
#include
char code led_mod[]={0x3f0x060x5b0x4f0x660x6d0x7d0x070x7f0x6f};
int secondminhour;
int setmin=0sethour=0;
int currentmincurrenthour;
bit flag=0;
bit timeflag=1;
bit time24to12=1;
bit amorpm=0;
sbit P16=P1^6;
unsigned char status;
void delay(int time)
{
int i;
for(;time>0;time--)
for(i=0;i<250;i++);
}
int0_key() interrupt 0{
flag=1;
status=P0;
}
void sound(int n)
{
int i=0;
P16=1;
while(i {
P16=!P16;
i++;
}
}
void main()
{
int time;
IP=0x01;
IT0=1;
EX0=1;
EA=1;
second=50;
currentmin=58;
min=currentmin;
currenthour=20;
hour=currenthour;
while(1)
{
time=0;
if(second>59)
{
second=0;
currentmin++;
min++;
}
if(min>59)
{
min=0;
hour++;
}
if(hour>23)
{
hour=0;
}
if(currentmin>59)
{
currentmin=0;
sound(10);
currenthour++;
}
if(currenthour>23)
{
currenthour=0;
}
while(time<50)
{
P1=0x01;
P2=~led_mod[second/10];
delay(1);
P1=0x02;
P2=~led_mod[second%10];
delay(1);
P1=0x04;
P2=~led_mod[min/10];
delay(1);
P1=0x08;
P2=~led_mod[min%10];
delay(1);
P1=0x10;
P2=~led_mod[hour/10];
delay(1);
P1=0x20;
P2=~led_mod[hour%10];
delay(1);
time++;
}
P1=0x00;
P2=0x00;
if(!timeflag)
delay(100);
second++;
if(currentmin==setmin&¤thour==sethour)
{
sound(10);
}
if(flag)
{
switch(status){
case 0:min++;
status=0x06;
break;
case 1:hour++;
status=0x06;
break;
case 2:if(timeflag)
{
currentmin=min;
min=setmin;
currenthour=hour;
hour=sethour;
}
else
{
setmin=min;
min=currentmin;
sethour=hour;
hour=currenthour;
}
timeflag=!timeflag;
status=0x06;
break;
case 3:if(time24to12)
{
if(currenthour>12)
amorpm=0;
else
amorpm=1;
currenthour=currenthour%12;
hour=currenthour;
}
else
{
if(amorpm)
currenthour=currenthour+12;
hour=currenthour;
}
time24to12=!time24to12;
flag=0;
break;
default:break;
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
-rw------- 2482 2013-12-19 14:16 update7seg.c
-rw------- 102486 2013-12-19 14:31 ClockShare.DSN
----------- --------- ---------- ----- ----
104968 2
- 上一篇:msix 微软msp文件提取
- 下一篇:完美破解word文档打开密码
相关资源
- bitcoin_vs2017.zip
- zw_SplashesTable.zip
- WMTorrent种子清洗器.zip
- 计算机组成原理第五版.txt
- guilv.rar
- IEEE5.doc
- zint-源代码.zip
- FPXHUSB-ok.rar
- k1uomw.rar
- shuiguopeidui.aia
- 霍夫变换找圆.zip
- 校园导航系统.rar
- fn_check_creditCode.rar
- -Lyapunov指数的计算方法.doc
- ADC0809.rar
- UBOOTloadb命令加载应用程序到SDRAM中运
- 华为设备-eNSP配置说明.doc
- haarcascade_mcs_mouth2019.rar
- 国家互联网安全中心面试准备材料.
- EV_RWD_2NEW.rar
- CORBA开源测试工具.pdf
- 登陆界面二2012-12-25.rar
- 区块链开发入门到精通全套视频.txt
- FZ4与三菱PLC通讯总结.docx
- 997783QTableWidget表头添加复选框.zip
- 4c0138bbb96b33332ad8287cd800de13.zip
- 2018机器学习试题.doc
- PatentDocuments.rar
- GOLAY.c
- WCD9335.pdf
评论
共有 条评论