C编程关于数字钟.doc_第1页
C编程关于数字钟.doc_第2页
C编程关于数字钟.doc_第3页
C编程关于数字钟.doc_第4页
C编程关于数字钟.doc_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

数字钟的C编程#include#define uchar unsigned char#define uint unsigned intsbit K1=P10;sbit K2=P11;sbit K3=P12;sbit K4=P13;sbit beep=P17;uchar code table1=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f;uchar table2=0,0,0,0,0,0;uchar code table3=0xfe,0xfd,0xfb,0xf7,0xef,0xdf;uchar i,j,h=12,m=0,s=0,k,t,s1,s2,g;void delayms(uint x)uint y;while(x-)for(y=120;y0;y-);void speak()for(i=0;i20;i+)beep=beep;delayms(10);void hour()h+;if(h=24)h=0;speak();void minute()m+;if(m=60)m=0;hour();void second()s+;if(s=60)s=0;minute();void T0_time() interrupt 1TH0=(65536-1000)/256;TL0=(65536-1000)%256;P3=table3j;P2=table2j;j=(j+1)%6;s2+;if(s2=200)s2=0;g=g;void T1_time() interrupt 3TH1=(65536-50000)/256;TL1=(65536-50000)%256;s1+;if(s1=20)s1=0;second();void main()P1=0xff;P2=0x00;P3=0xff;TMOD=0x11;TH0=(65536-1000)/256;TL0=(65536-1000)%256;TH1=(65536-50000)/256;TL1=(65536-50000)%256;EA=1;ET0=1;ET1=1;TR0=1;TR1=1;while(1)if(K4=0)delayms(10);if(K4=0)t=t;while(K4=0);if(t=0)if(K1=0)delayms(10);if(K1=0)k=(k+1)%3;while(K1=0);switch(k)case 0:ET1=0;if(K2=0)delayms(10);if(K2=0)s=(s+1)%60;while(K2=0);else if(K3=0)delayms(10);if(K3=0)if(s=0)s=60;s-;while(K3=0);table20=table1h/10;table21=table1h%10;table22=table1m/10;table23=table1m%10;table24=table1s/10&g;table25=table1s%10&g;break;case 1:ET1=1;if(K2=0)delayms(10);if(K2=0)m=(m+1)%60;while(K2=0);else if(K3=0)delayms(10);if(K3=0)if(m=0)m=60;m-;while(K3=0);table20=table1h/10;table21=table1h%10;table22=table1m/10&g;table23=table1m%10&g;table24=table1s/10;table25=table1s%10;break;case 2:if(K2=0)delayms(10);if(K2=0)h=(h+1)%24;while(K2=0);else if(K3=0)delayms(10);if(K3=0)if(h=0)h=24;h-;while(K3=0); table20=table1h/10&g; table21=table1h%10&g;table22=table1m/10;table23=table1m%10;table24=table1s/10;table25=table1s%10;break;else ET1=1;table20=table1h/10;ta

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论