全国电子专业技术人才考试Word格式文档下载.docx
- 文档编号:16870542
- 上传时间:2022-11-26
- 格式:DOCX
- 页数:9
- 大小:15.84KB
全国电子专业技术人才考试Word格式文档下载.docx
《全国电子专业技术人才考试Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《全国电子专业技术人才考试Word格式文档下载.docx(9页珍藏版)》请在冰豆网上搜索。
2、EEPROM数据存储,存储内容分段信息,交通灯亮灭的时间,EEPROM使用24C02;
3、有一个按键,可以按顺序切换时间段!
4、数据格式如下:
序号
时间段(秒)
灯
1
9时----12时
45
红
5
黄
90
绿
2
12时----14时
60
3
14时----18时
70
55
4
18时----22时
22时----9时
二、软件
1、首先将表格中的数据存入EEPROM中
2、要求EEPROM中的显示红、绿、黄灯的亮灭以及倒计时时间。
3、将调试好的程序附在表格下面。
附加说明:
要求在三个小时之内完成以上功能,并将做好的文档压缩成rar或Zip格式,交于监考人员!
单片机I/O定义:
定义数码管:
段、位
24C02管脚定义
按键定义Key=P1^0;
程序:
#include"
reg51.h"
sbitLED0=P0^0;
sbitLED4=P0^1;
sbitLED3=P0^2;
sbitLED2=P0^3;
sbitLED1=P0^4;
sbitKey=P1^0;
codeunsignedcharLedSeg[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
voidDelay2ms(unsignedintDTime);
voidDelay2ms(unsignedintDTime)
{
unsignedintCnt;
for(Cnt=0;
Cnt<
30*DTime;
Cnt++);
}
voidmain()
{
unsignedcharHour=9,Minute,Second,Second_=45,L3,L4;
unsignedcharFlag1=1,Flag2=0,Flag3=0,F=0;
unsignedintwCnt=0,KeyFlag=0;
while
(1)
{
Delay2ms
(1);
wCnt++;
if(wCnt>
500)
wCnt=0;
if(++Second>
59)
{
Second=0;
if(++Minute>
Minute=0;
if(++Hour>
23)
{
Hour=0;
}
}
if(--Second_<
0)
F=1;
}
//**************************************************************************
if(F)
if((Hour>
=9&
&
Hour<
=12)||KeyFlag==0)
Flag1=0;
Flag2=1;
Second_=5;
if(Flag2==1)
Flag2=0;
Flag3=1;
Second_=90;
if(Flag3==1)
Flag3=0;
Flag1=1;
Second_=60;
if((Hour>
12&
=14)||KeyFlag==1)
Flag1=0;
Second_=60;
Second_=70;
14&
=18)||KeyFlag==2)
Second_=55;
Flag1=1;
Second_=90;
18&
=22)||KeyFlag==3)
Second_=45;
Second_=70;
22&
=24&
9)||KeyFlag==4)
L4=Second_%10;
L3=Second_/10;
switch(wCnt%5)
case0:
P0=0;
LED0=1;
if(Flag1)
P2=LedSeg[8];
else
P2=LedSeg[0];
break;
case1:
LED1=1;
if(Flag2)
case2:
LED2=1;
if(Flag3)
case3:
LED3=1;
P2=LedSeg[L3];
case4:
LED4=1;
P2=LedSeg[L4];
if(Key==0)
Delay2ms(5);
KeyFlag++;
while(Key==0);
//等待开关放开
if(KeyFlag==5)
KeyFlag=0;
}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 全国 电子 专业技术人才 考试
![提示](https://static.bdocx.com/images/bang_tan.gif)