analog输出实现呼吸灯效果
如题。连线:程序:
int brightMAX=63;
int brightness=0;
int brightFlag=-1;
int ledOut=3;
void setup() {
}
void loop() {
if(brightness==brightMAX || brightness==0)
{
brightFlag=-brightFlag;
}
brightness+=brightFlag;
analogWrite(ledOut, brightness);
if(brightness==0 || brightness==brightMAX)
{
delay(200);
}
else
{
delay(10);
}
}
效果:
:D真不错,学习学习。 学习了,谢谢
页:
[1]