#include <intrins.h>
void delayms(unsigned char ms)
// 延时子程序
{
unsigned char i
while(ms--)
{
for(i = 0i <120i++)
}
}
main()
{
unsigned char LED
LED = 0xfe //0xfe = 1111 1110
while(1)
{
P2 = LED
delayms(250)
LED = LED <<1 //循环右移1位,点亮下一个LED "<<"为左移位
if(P2 == 0x00 ) {LED = 0xfe } // 0xfe = 1111 1110
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)