




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include reg51.h#include#define uint unsigned char#define uchar unsigned char#define THCO 0xee#define TLCO 0x0uchar i,n;uint H,L;void delay(uint);uchar code table=0xfd,0x09,0x04,0xfd,0x09,0x04, 0xfd,0x34,0x04,0xfd,0x83,0x04,0xfd,0x83,0x04,0xfd,0x34,0x04,0xfd,0x09,0x04,0xfc,0xad,0x04,0xfc,0x44,0x04,0xfc,0x44,0x04,0xfc,0xad,0x04,0xfd,0x09,0x04,0xfd,0x09,0x04,0xfc,0xad,0x04,0xfc,0xad,0x08,0xfd,0x09,0x04,0xfd,0x09,0x04, 0xfd,0x34,0x04,0xfd,0x83,0x04,0xfd,0x83,0x04,0xfd,0x34,0x04,0xfd,0x09,0x04,0xfc,0xad,0x04,0xfc,0x44,0x04,0xfc,0x44,0x04,0xfc,0xad,0x04,0xfd,0x09,0x04,0xfc,0xad,0x04,0xfc,0x44,0x04,0xfc,0x44,0x08;unsigned char code Duan=0x3F, 0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F;/共阴极数码管,0-9段码表unsigned char Data_Buffer10=0,1,2,3,4,5,6,7,8,9;/四个数码管显示数值,数组变量定义 static unsigned char Bit=0;/静态变量,退出程序后,值保留 static unsigned char Bit1=0; static unsigned char Bit2=0; static unsigned char Bit3=0; static unsigned char Bit4=0; static unsigned char Bit5=0; static unsigned char Bit6=0; static unsigned char Trouch=0; sbit P10=P10; /四个数码管的位码口定义 sbit P27=P27; sbit P26=P26; sbit P25=P25; sbit P24=P24; sbit P23=P23;sbit P20=P20;sbit P21=P21; sbit P3_2=P32;sbit P11=P11;sbit P12=P12;sbit P13=P13;sbit P14=P14;/四个数码管的位码口定义sbit P15=P15;sbit P16=P16;sbit P17=P17;void delay(int i)unsigned int a,b;for(a=i;a0;a-);for(b=100;b0;b-); void change6() P26=0;P25=0; delay(150000) ;doif(P21=0)Bit6+;if(Bit6=2)Bit6=0;P0=DuanData_BufferBit1; /开段码 P1=0xdf;delay(50); P0=DuanData_BufferBit2; P1=0xef;delay(50);/先关位码 P0=DuanData_BufferBit3; /开段码 P1=0xf7;delay(50); P0=DuanData_BufferBit4; P1=0xfb;delay(50);/先关位码 P0=DuanData_BufferBit5; /开段码 P1=0xfd;delay(50); P0=DuanData_BufferBit6; P1=0xfe;delay(50); while(P20=1);P26=1;P25=1;delay(25000);void change5() P24=0; P26=0; delay(150000) ;doif(P21=0)Bit5+;if(Bit5=4)Bit5=0;P0=DuanData_BufferBit1; /开段码 P1=0xdf;delay(50); P0=DuanData_BufferBit2; P1=0xef;delay(50);/先关位码 P0=DuanData_BufferBit3; /开段码 P1=0xf7;delay(50); P0=DuanData_BufferBit4; P1=0xfb;delay(50);/先关位码 P0=DuanData_BufferBit5; /开段码 P1=0xfd;delay(50); P0=DuanData_BufferBit6; P1=0xfe;delay(50); while(P20=1);P24=1; P26=1;delay(25000);change6(); void change4() P24=0; delay(150000) ;doif(P21=0)Bit4+;if(Bit4=6)Bit4=0;P0=DuanData_BufferBit1; /开段码 P1=0xdf;delay(50); P0=DuanData_BufferBit2; P1=0xef;delay(50);/先关位码 P0=DuanData_BufferBit3; /开段码 P1=0xf7;delay(50); P0=DuanData_BufferBit4; P1=0xfb;delay(50);/先关位码 P0=DuanData_BufferBit5; /开段码 P1=0xfd;delay(50); P0=DuanData_BufferBit6; P1=0xfe;delay(50); while(P20=1);P24=1;delay(25000); change5();void change3() P25=0;P26=0; delay(150000) ;doif(P21=0)Bit3+;if(Bit3=10)Bit3=0;P0=DuanData_BufferBit1; /开段码 P1=0xdf;delay(50); P0=DuanData_BufferBit2; P1=0xef;delay(50);/先关位码 P0=DuanData_BufferBit3; /开段码 P1=0xf7;delay(50); P0=DuanData_BufferBit4; P1=0xfb;delay(50);/先关位码 P0=DuanData_BufferBit5; /开段码 P1=0xfd;delay(50); P0=DuanData_BufferBit6; P1=0xfe;delay(50); while(P20=1);P25=1;P26=1; ;delay(25000); change4(); void change2() P25=0; delay(150000) ;doif(P21=0)Bit2+;if(Bit2=6)Bit2=0;P0=DuanData_BufferBit1; /开段码 P1=0xdf;delay(50); P0=DuanData_BufferBit2; P1=0xef;delay(50);/先关位码 P0=DuanData_BufferBit3; /开段码 P1=0xf7;delay(50); P0=DuanData_BufferBit4; P1=0xfb;delay(50);/先关位码 P0=DuanData_BufferBit5; /开段码 P1=0xfd;delay(50); P0=DuanData_BufferBit6; P1=0xfe;delay(50);P2=0xdf; while(P20=1);P25=1;delay(25000); change3();void change1() P26=0; delay(150000) ;doif(P21=0)Bit1+;if(Bit1=10)Bit1=0;P0=DuanData_BufferBit1; /开段码 P1=0xdf;delay(50); P0=DuanData_BufferBit2; P1=0xef;delay(50);/先关位码 P0=DuanData_BufferBit3; /开段码 P1=0xf7;delay(50); P0=DuanData_BufferBit4; P1=0xfb;delay(50);/先关位码 P0=DuanData_BufferBit5; /开段码 P1=0xfd;delay(50); P0=DuanData_BufferBit6; P1=0xfe;delay(50); while(P20=1);P26=1; delay(25000); change2();void main()PX0=1;EX0=1;/沿触发方式IT0=1; TMOD=0x01;/定时器0初始化 TH0=THCO; TL0=TLCO; TR0=1; ET0=1; EA=1;TMOD=0x10;EA=1;/开总中断ET1=1;/开T1中断for(i=0;i=100) Bit=0; Bit1+; if(Bit1=9)Bit1=0;Bit2+; if(Bit2=6)Bit2=0;Bit3+; if(Bit3=9)Bit3=0;Bit4+; if(Bit4=6) Bit4=0;Bit5+; if(Bit5=4)Bit5=0;Bit6+; if(Bit6=2)Bit6=0; /先关位码 P1=0xff;/先关位码 P0=DuanData_BufferBit1; /开段码 P1=0xdf;delay(50); P0=DuanData_BufferBit2; P1=0xef;delay(50);/先关位码 P0=DuanData_BufferBit3; /开段码 P1=0xf7;delay(50); P0=DuanData_BufferBit4; P1=0xfb;delay(50);/先关位码 P0=DuanData_BufferBit5; /开段码 P1=0xfd;delay(50); P0=DuanData_BufferBit6; P1=0xfe; delay(50); void time1() interrupt 3TH1=H;TL1=L;P3_2=P3_2; void int0() interrupt 0 do P27=!P27;delay(50); P1=0xff;/先关位码 P0=DuanData_BufferBit1; /开段码 P1=0xdf;delay(50); P0=DuanData_BufferBi
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二零二五年度猪场租赁与养殖废弃物资源化利用合作协议
- 2025年度危化品物流承包装卸搬运及安全防护合同
- 二零二五年度董事职责履行与聘任合同
- 2025年度学生安全教育与应急演练合作协议
- 2025年度医院食堂营养均衡供餐服务协议
- 2025年度农产品电商平台购销合同图片制作与物流服务合同
- 2025年度夫妻共同财产投资决策及收益共享协议书
- 2025年吉林职业技术学院单招职业技能测试题库及参考答案
- 2025年度保障房东权益的商铺租赁合同要点
- 2025年度债务转移与债务清偿合同范本
- 小班安全《汤姆走丢了》PPT课件教案反思微视频
- 作物栽培学课件棉花
- 最新小学二年级口算及竖式计算练习题
- 生产与运作管理-陈荣秋
- 病理生理学教学病生6休克课件
- 金鸡冠的公鸡绘本课件
- 日影朝向及长短
- 沙盘游戏治疗(课堂PPT)
- (完整版)学生的自我评价的表格
- 朴素贝叶斯分类器完整
- 教育系统绩效工资分配方案(共6页)
评论
0/150
提交评论