欢迎来到天天文库
浏览记录
ID:16859239
大小:104.54 KB
页数:20页
时间:2018-08-25
《单片机原理及应用实验》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、北京航空航天大学单片机实验51otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeen
2、theNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersand19/20实验一单片机开发环境以及I/O使用实验1、#include//89S52寄存器定义头文件/*---延时子程序(有参函数),t=n*10ms
3、---*/voiddelay(unsignedcharn){unsignedchari,j,k;for(i=0;i//89S52寄存器定义头文件voidmain(){wh
4、ile(1){P0=0xff;//对端口写"1",作为高阻抗输入端用if(P0_0)//判断P0.0是否为高电平{P1_0=0;}else//如果P0.0不是高电平,则执行后面的语句{P1_0=1;}}}3、#include//89S52寄存器定义头文件/*---延时子程序(有参函数),t=n*10ms---*/#defineK1P0_0#defineK2P0_1#defineL1P1_0#defineL2P1_1#defineL3P1_2#defineL4P1_3#defineL5P1_4#defineL6P1_
5、5#defineL7P1_6#defineL8P1_7otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMar
6、ch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersand19/20voiddelay(unsignedcharn){unsignedchari,j,k;for(i=0;i7、<14;j++)for(k=0;k<237;k++);}/*******正循环******/voidway1(){while(K1==0&&K2==0){staticunsignedcharposition=0;P1=1<=8)position=0;delay(100);}}/*******逆循环******/voidway2(){while(K1==0&&K2==1){staticunsignedcharposition=0;P1=128>>position;if(++position>8、=8)position=0;delay(100);}}/*******交替闪烁******/voidway3(){while(K1==1&&K2==0){P1=0X55;delay(100);P1=0xAA
7、<14;j++)for(k=0;k<237;k++);}/*******正循环******/voidway1(){while(K1==0&&K2==0){staticunsignedcharposition=0;P1=1<=8)position=0;delay(100);}}/*******逆循环******/voidway2(){while(K1==0&&K2==1){staticunsignedcharposition=0;P1=128>>position;if(++position>
8、=8)position=0;delay(100);}}/*******交替闪烁******/voidway3(){while(K1==1&&K2==0){P1=0X55;delay(100);P1=0xAA
此文档下载收益归作者所有