- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
十天学会单片中的源程序
Lesson2-1
#includereg52.h
sbit p1_1=P1^0
unsigned int a
void main()
{
while(1)
{
a=51000;
p1_1=0;
while(a--);
a=51000;
while(a--);
p1_1=1;
a=51000;
while(a--);
a=51000;
while(a--);
}
}
Lesson2-2
#includereg52.h
#define uint unsigned int
#define uchar unsigned char
sbit D1=P1^0;
//void delay();
void delay(uint);
void main()
{
while(1)
{
D1=0;
delay(100);
D1=1;
delay(100);
}
}
/*
void delay()
{
uint x,y;
for(x=100;x0;x--)
for(y=600;y0;y--);
}*/
void delay(uint z)
{
uint x;
uchar y;
for(x=z;x0;x--)
for(y=20;y0;y--);
}
Lesson2-3
#includereg52.h
#include intrins.h
#define uint unsigned int
#define uchar unsigned char
uchar temp,num,num1;
sbit beep=P2^3;
void delay(uint);
void main()
{
temp=0xfe;
while(1)
{
for(num1=0;num13;num1++)
{
for(num=0;num8;num++)
{
P1=temp;
beep=0;
delay(100);
temp=_crol_(temp,1);
P1=0xff;
beep=1;
delay(100);
}
}
for(num1=0;num13;num1++)
{
for(num=0;num8;num++)
{
P1=temp;
beep=0;
delay(100);
temp=_cror_(temp,1);
P1=0xff;
beep=1;
delay(100);
}
}
while(1);
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x0;x--)
for(y=110;y0;y--);
}
Lesson3-1
#includereg52.h
sbit dula=P2^6;
sbit wela=P2^7;
void main()
{
wela=1;
P0=0xc0;
wela=0;
dula=1;
P0=0x06;
dula=0;
while(1);
}
Lesson3-2
#includereg52.h
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
uchar num;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void main()
{
wela=1;/ P0=0xea;
wela=0;
while(1)
{
for(num=0;num16;num++)
{
dula=1;
P0=table[num];
dula=0;
delay(1000);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x0;x--)
for(y=110;y0;y--);
}
Lesson3-3
#includereg52.h
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
sbit d1=P1^0;
uchar num;
uchar code table[]={
0x3f
您可能关注的文档
最近下载
- 2023年外贸单证实务试卷题库和答案.doc VIP
- 消防安全重点单位消防档案.docx VIP
- 考前必备2025年四川省巴中市公务员省考公共基础知识测试卷(含答案.pdf VIP
- 教学课件:《思想政治学科教学新论》(第二版)刘强.ppt
- 2025云南怒江州福贡县义务教育教师专项招聘65人笔试备考试题及答案解析.docx VIP
- Unit 3 课时5 Word power(课件)-2025-2026学年八年级英语上册(译林版2024).pptx
- DB44/T 2457-2024地质灾害自动化监测规范.docx
- 流程制度文件评审制度及表单.docx VIP
- 2025年职业学院专任教师辅导员招聘考试笔试试题(含答案).docx VIP
- 基于BIM技术的铁路施工管理与协同方案研究.pptx VIP
文档评论(0)