《单片机C语言程序设计实训100例---基于8051和PROTEUS仿真》案例
01 闪烁的LED
LED 名称:闪烁的/*
按设定的时间间隔闪烁 说明:LED*/
#includereg51.h
#define uchar unsigned char
#define uint unsigned int
sbit LED=P1^0;
延时//void DelayMS(uint x)
{
uchar i;
while(x--)
{
for(i=0;i120;i++);
}
}
//主程序void main()
{
while(1)
{
LED=~LED;
DelayMS(150);
}
}
02 从左到右的流水灯
名称:从左到右的流水灯/*
LED个接在P0口的8 说明:产生走从左到右循环依次点亮, 马灯效果*/
#includereg51.h
#includeintrins.h
#define uchar unsigned char
#define uint unsigned int
延时//void DelayMS(uint x)
{
uchar i;
while(x--)
{
1
上海师范大学信息与机电工程学院—倪继锋
《单片机C语言
原创力文档

文档评论(0)