void delay(uint16_tx)
{
uint16_ti;
while(x--)
for(i=0;i<130;i++);
}
调用delay()时参数赋值为1500感觉竟是那么快,记得以前在52上1500差不多就代表延时1.5s
关键代码:
void main(void)
{
/* Start user code. Do not edit comment generated here */
uint8_t j;
uint8_t m;
PM2 &=0x00;
m=0xff;
while (1U)
{
for(j=0; j<9; j++)
{
P2=m;
m=m<<1;
delay(1500);
}
m=0xff;
}
/* End user code. Do not edit comment generated here */
}
效果展示:
![](http://uphotos.eepw.com.cn/hixin1991/pics/305216f3fc4f4fcd07806f96987fe65d.jpg)
![](http://uphotos.eepw.com.cn/hixin1991/pics/8d6b32508e3c4bcc4acd3f86b867e400.jpg)