- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
单片机例子闪烁的LED灯推荐
1.闪烁的LED灯#include reg52.h#define uchar unsigned char#define uint unsigned intsbit LED = P1^0;voidDelayMS(uint x){uchari;while(x--){for(i=120;i0;i--);}}void main(){while(1){LED = ~LED;DelayMS(150);}}2.从左到右的流水灯#include reg52.h#include intrins.h#define uchar unsigned char#define uint unsigned intvoidDelayMS(uint x){uchari;while(x--){for(i=120;i0;i--);}}void main(){P0 = 0xFE;while(1){P0 = _crol_(P0,1);DelayMS(150);}}3.左右来回的流水灯#include reg52.h#include intrins.h#define uchar unsigned char#define uint unsigned intvoidDelayMS(uint x){uchar t;while(x--){for(t=120;t0;t--);}}void main(){uchari;P2=0x01;while(1){for(i=7;i0;i--){P2=_crol_(P2,1);DelayMS(150);}for(i=7;i0;i--){P2=_cror_(P2,2);DelayMS(150);}}}4.花样流水灯程序#include reg52.h#define uchar unsigned char#define uint unsigned intuchar code Pattern_P0[]={0xfc,0xf9,0xf3,0xe7,0xcf,0x9f};uchar code Pattern_P2[]={0xf5,0xf6,0xfe,0x54,0x56,0x76,0xd7,0x49,0xa9,0xe4,0xc6};voidDelayMS(uint x){uchar t;while(x--){for(t=120;t0;t--);}}void main(){uchari;while(1){for(i=136;i0;i--){P0=Pattern_P0[i];P2=Pattern_P2[i];DelayMS(150);}}}5.LED交通模拟灯#include reg52.h#define uchar unsigned char#define uint unsigned intsbit RED_A=P0^0;sbit YELLOW_A=P0^1;sbit GREEN_A=P0^2;sbit RED_B=P0^3;sbit YELLOW_B=P0^4;sbit GREEN_B=P0^5;ucharFlash_Count = 0;Operation_Type = 1;voidDelayMS(uint x){uchar t;while(x--){for(t=120;t0;t--);}}voidTraffic_lignt(){switch(Operation_Type){case 1:RED_A=1;YELLOW_A=1;GREEN_A=0;RED_B=0;YELLOW_B=1;GREEN_B=1;DelayMS(2000);Operation_Type = 2;break;case 2:DelayMS(200);YELLOW_A=~YELLOW_A;if(++Flash_Count !=10) return;Flash_Count=0;Operation_Type = 3;break;case 3:RED_A=0;YELLOW_A=1;GREEN_A=1;RED_B=1;YELLOW_B=1;GREEN_B=0;DelayMS(2000);Operation_Type = 4;break;case 4:DelayMS(200);YELLOW_B=~YELLOW_B;if(++Flash_Count !=10) return;Flash_Count=0;Operation_Type = 1;break;}}void main(){while(1){Traffic_lignt();}}6.单只数码管显示0到9#include reg52.h#include intrins.h#define uchar unsigned char#define uint unsigned intuchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb
您可能关注的文档
最近下载
- 中国染料化工项目经营分析报告.docx
- 专题04:论证结构与思路-备战2025年中考语文一轮复习现代文阅读讲与练(江苏通用)(解析版).docx VIP
- 初中英语读写结合模式促进写作教学的探讨.pptx VIP
- 2025年中国DBE项目创业投资方案.docx
- 堤顶混凝土路面施工方案堤顶混凝土路面施工方案.doc VIP
- 筑牢金融数字防线:商业银行信息安全风险管理体系的构建与革新.docx
- 《人力资源管理师三级》第五章薪酬管理.ppt
- 《让子弹飞》剧本.doc VIP
- 2025年水环境服务项目可行性分析报告.docx
- DB4201T 620-2020 液化石油气供气场站设置技术规定.docx VIP
文档评论(0)