const int led[] ={3,5,6,9,10,11};
int brightness=0;
int lighten=5;
int ledNums=0;
int direct=0;
void setup()
{
}
void loop()
{
while(1)
{
if(direct==0)
{
brightness=brightness+lighten;
if(brightness>=250)
direct=1;
analogWrite(led[ledNums],brightness);
delay(10);
}
else
{
brightness=brightness-lighten;
analogWrite(led[ledNums],brightness);
delay(10);
if(brightness<=5)
{
analogWrite(led[ledNums],0);
direct=0;
ledNums=ledNums+1;
if(ledNums>5)
ledNums=0;
}
}
}
}
沒有留言:
張貼留言