int led[]={3,5,6,9};
void setup()
{
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(9,OUTPUT);
}
//-------------------------------------------------
void led0()
{
for(int i=0;i<=255;i++)//呼吸燈slow變亮
{
analogWrite(3,i);
delay(10);
}
for(int i=255;i>=0;i--)//呼吸燈slow變暗
{
analogWrite(3,i);
delay(10);
}
}
//-------------------------------------------------
void led1()
{
for(int i=0;i<=255;i++)//呼吸燈slow變亮
{
analogWrite(5,i);
delay(10);
}
for(int i=255;i>=0;i--)//呼吸燈slow變暗
{
analogWrite(5,i);
delay(10);
}
}
//-----------------------------------------------------
void led2()
{
for(int i=0;i<=255;i++)//呼吸燈slow變亮
{
analogWrite(6,i);
delay(10);
}
for(int i=255;i>=0;i--)//呼吸燈slow變暗
{
analogWrite(6,i);
delay(10);
}
}
//-------------------------------------------------
void led3()
{
for(int i=0;i<=255;i++)//呼吸燈slow變亮
{
analogWrite(9,i);
delay(10);
}
for(int i=255;i>=0;i--)//呼吸燈slow變暗
{
analogWrite(9,i);
delay(10);
}
}
void loop()
{
led0();
led1();
led2();
led3();
}
沒有留言:
張貼留言