交通灯编程要求及程序.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
#include reg51.h #define GPIO_PLACE P1 #define GPIO_DIG P0 void Delay10ms(unsigned int); void DigDisplay(); unsigned char code DIG_PLACE[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; unsigned char code DIG_CODE[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; unsigned char DisplayData[8]; //unsigned char emergency = 0; // 0 无特殊情况 1 有特殊情况发生 sbit K1_R=P2^0; sbit K1_Y=P2^1; sbit K1_G=P2^2; sbit K2_R=P2^5; sbit K2_Y=P2^4; sbit K2_G=P2^3; unsigned char b=1,c,Second,Time; void main() { TMOD = 0x01; //定时器0选择工作方式1 TH0 = 0x3C; //设置初始值,定时50MS TL0 = 0xB0; ET0 = 1; //打开定时器0中断 EX0 =1; //INT0中断开 EA = 1; //打开总中断 IP =0X02; //INT0优先级高 TR0 = 1; //启动T0 IT0 =1; //INT0下降沿触发 while(1) { Second = 1; for(c=0;c4;c++) { switch(b) { case 1: for(;Second41;) { DisplayData[0] = 0x00; DisplayData[1] = 0x00; DisplayData[2] = DIG_CODE[(41 - Second) % 100 / 10]; DisplayData[3] = DIG_CODE[(41 - Second) %10]; DisplayData[4] = 0x00; DisplayData[5] = 0x00; DisplayData[6] = DisplayData[2]; DisplayData[7] = DisplayData[3]; K1_G=0; K1_R=1; K1_Y=1; K2_G=1; K2_R=0; K2_Y=1; DigDisplay(); } b=2; break; case 2: for(;Second44;) { DisplayData[0] = 0x00; DisplayData[1] = 0x00; DisplayData[2] = DIG_CODE[(44 - Second) % 100 / 10]; DisplayData[3] = DIG_CODE[(44 - Second) %10]; DisplayData[4] = 0x00; DisplayData[5] = 0x00; DisplayData[6] = DIG_CODE[(61 - Second) % 100 / 10]; DisplayData[7] = DIG_CODE[(61 - Second) %10]; DigDisplay(); K1_G=1; K2_R=1; K2_G=0; K1_Y=0; } b=3; break; case 3: for(;Second61;) { DisplayData[0] = 0x00; DisplayData[1] = 0x00; DisplayData[2] = DIG_CODE[(64 - Second) % 100 / 10]; DisplayData[3] = DIG_CODE[(64 - Second) %10]; DisplayData[4] = 0x00; DisplayData[5] = 0x00; DisplayData[6] = DIG_

文档评论(0)

dashewan + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档