基于51数码管显示的万年历(仿真+程序)
更新时间:2024-01-09 22:46:01 阅读量: 教育文库 文档下载
- 万年历数码管显示不全推荐度:
- 相关推荐
基于数码管显示的万年历(proteus仿真+C程序)
Proteus仿真图
项目名称:万年历U6B03B14B27B38B413B514B61718D0D1D2D3D4D5D6D7OELE74S373Q0Q1Q2Q3Q4Q5Q6Q7256912151619D0D1D2D3D4D5D6U119D0D1D2D3D4D5D6XTAL1A21A20A19A18A17A1618XTAL29SEC_SETRSTP0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD393837363534333221222324252627281011121314151617B0B1B2B3B4B5B6111U3123ABCY0Y1Y2Y3Y4Y5Y6Y715141312111097A0A1A2A3A4A5A6A7MIN_SET293031PSENALEEAHOU_SET12345678P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C51MON_SET645E1E2E374LS138WEEK_SETU4123ABCY0Y1Y2Y3Y4Y5Y6Y715141312111097A8A9A10A11A12A13A14A15D0D1D2D3D4D5D6A15A14A13A12A11A10A9A8DAY_SET645YEAR_SETE1E2E374LS138ADD_SUB123U5ABCY0Y1Y2Y3Y4Y5Y6Y715141312111097A16A17A18A19A20A21A7A6A5A4A3A2A1A0645E1E2E374LS138说明:通过数码管显示一个初始时间,不能记忆时间作者:LINLIANHUO日期:2014年07月25日D0D1D2D3D4D5D6 C语言程序
/*********************************************************
TITLE: 万年历设计
FUNCTION: 显示:年-月-日-星期-时-分-秒 WRITER: LINLIANHUO TIME: 2014-07-24
REMARK: 译码扫描时间不能过长,否则无法实现调整 *******************************************************
***/
#include
/***********码表***************/
uchar code smg_table[]={0xBF,0x86,0xDB,0xCF,0xE6,
uchar code months_days[]={31,28,31,30,31,30,31,31,30,31,30,31};
uchar code transcode[]={0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,
uchar buffer[22]={0};
/**********数据定义*********/ uchar add_sub; uchar key_detection=0; uchar count=0;
0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,
0xED,0xFD,0xA7,0xFF,0xEF,0xC0};
0xee,0xef,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd};
typedef struct {
uchar year[2];
uchar month; uchar day; uchar week;
}date;
typedef struct {
uchar hour;
uchar minute; uchar second;
}moment;
date today={{14,20},7,25,5}; moment now={16,52,45};
/**********延时子程序*************/ void delay() {
uchar i,j; }
/**********数码管显示子程序***********/ void smg_display() {
uchar i;
buffer[8]=today.week; buffer[9]=today.week/10; buffer[10]=10;
buffer[0]=now.second; buffer[1]=now.second/10; buffer[2]=10;
buffer[3]=now.minute; buffer[4]=now.minute/10; buffer[5]=10;
buffer[6]=now.hour; buffer[7]=now.hour/10; for(i=0;i<=8;i++)
for(j=0;j<40;j++);
}
buffer[11]=today.day; buffer[12]=today.day/10; buffer[13]=10;
buffer[14]=today.month; buffer[15]=today.month/10;
buffer[16]=10;
buffer[17]=today.year[0]; buffer[18]=today.year[0]/10; buffer[19]=today.year[1]; buffer[20]=today.year[1]/10; buffer[21]=10;
for(i=0;i<22;i++) {
P0=smg_table[buffer[i]]; }
P2=transcode[i]; delay(); P2=0xff;
}
}
}
}
}
{
today.month=1; }
today.year[0]=today.year[0]+1; if(today.year[0]>=100) {
today.year[0]=0;
today.year[1]=today.year[1]+1; }
if(today.year[1]==100) {
today.year[1]=0; }
}
smg_display();
/*************INT0中断服务子程序*****************/
void int0_int() interrupt 0 using 1 {
uchar k; switch(add_sub) {
case 0x80:switch(key_detection) {
case 0xfe: {
now.second++; if(now.second>=60)
smg_display();
}break; case 0xfd: {
now.minute++; if(now.minute>=60)
smg_display();
}break; case 0xfb: {
now.hour++;
now.second=0; now.minute=0;
if(now.hour>=24) now.hour=0; smg_display();
}break; case 0xf7: {
today.week++;
if(today.week>=8) today.week=1; smg_display();
}break; case 0xef: {
today.day++;
k=leap_year(today.year[1],today.year[0]); if((k==1)&&(today.month==2)) {
if(today.day>=30) today.day=1; } else
if(today.day>=months_days[today.month-1])
today.day=1;
smg_display();
}break; case 0xdf: {
today.month++;
if(today.month>=13) today.month=1; smg_display();
}break; case 0xbf: {
today.year[0]=today.year[0]+1;
if(today.year[0]>=100) {
today.year[0]=0;
today.year[1]=today.year[1]+1; }
smg_display();
if(today.year[1]==100) today.year[1]=0;
}break;
default:{EA=1;EX0=0;TR0=1;}break;
}break;
case 0x00:switch(key_detection) {
case 0x7e: {
//now.second++;
if(now.second>0) now.second--; else now.second=59; smg_display();
}break; case 0x7d: {
//now.minute++;
if(now.minute>0) now.minute--; else now.minute=59; smg_display();
}break; case 0x7b: {
//now.hour++;
if(now.hour>0) now.hour--; else now.hour=23; smg_display();
}break; case 0x77: {
//today.week++;
if(today.week>1) today.week--; else today.week=1; smg_display();
}break; case 0x6f: {
//today.day++;
k=leap_year(today.year[1],today.year[0]); if((k==1)&&(today.month==2)) {
if(today.day>1) today.day--; } else {
if(today.day>1) today.day--; else
else today.day=29;
today.day=months_days[today.month-1];
}
smg_display();
}break; case 0x5f: {
//today.month++;
if(today.month>1) today.month--; else today.month=12; smg_display();
}break; case 0x3f: {
//today.year[0]=today.year[0]+1;
if(today.year[0]>0)
today.year[0]=today.year[0]-1; else {
today.year[0]=99;
today.year[1]=today.year[1]-1; }
smg_display();
}
}
}break;
default:{EA=1;EX0=0;TR0=1;}break;
}break;
正在阅读:
基于51数码管显示的万年历(仿真+程序)01-09
继电保护第四章课后习题参考答案资料讲解03-20
6#主体施工方案04-17
学习杜郎口中学教学模式反思02-07
电力系统分析课程设计不对称故障分析与计算的程序设计03-08
宜家的体验营销08-07
关于城乡幼儿园教育差异的调研报告01-23
最新的英语四级分数换算方法12-25
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 数码管
- 万年历
- 仿真
- 基于
- 程序
- 显示
- 少数民族知识竞赛试题
- 数据库期末单选练习&答案 200题 题库(必考)
- 中国山泉水行业深度调研及未来五年投资方向分析报告
- 资源与运营管理
- 浅析浅析托福听力怎么记笔记
- 新概念43-48教案讲义
- 北京大学经营创新与管理方略(EMBA)高级研修班 - 图文
- 100个成语解释
- 《天安门广场》集体备课稿
- 2010年深圳市初中毕业生学业考试英语全真模拟试卷(一)
- 一道习题的反思
- A4005两道支护参数修改专项安全技术措施
- 工业工程导论-浅谈工业工程在富士康的应用
- SSLVPN解决方案
- 重庆市职称改革办公室关于印发重庆市高职高专院校教师高级职务任职资格申报评审条件(试行)的通知
- 小学教师资格《综合素质》考试大纲
- 计算机网络考研知识点
- 地理标志产品(银杏) - 图文
- 服务技巧课后习题(理论考试)
- 某某某同志考察材料