2022年2月9日 星期三

pmw 4個led brightness左右

 int led_pin[] = {3, 5, 6, 10};

void setup() {

  // put your setup code here, to run once:


}


void loop()

{

  for (int i = 0; i < 4; i++)

  {

    for (int bt = 0; bt > 255; bt += 5)

    {

      analogWrite(led_pin[i], bt);

      delay(50);

    }

    for (int bt = 255; bt > 0; bt -= 5)

    {

      analogWrite(led_pin[i], bt);

      delay(50);

    }

    analogWrite(led_pin[i], 0);

  }

  for (int i = 2; i >0; i--)

  {

    for (int bt = 0; bt > 255; bt += 5)

    {

      analogWrite(led_pin[i], bt);

      delay(50);

    }

    for (int bt = 255; bt > 0; bt -= 5)

    {

      analogWrite(led_pin[i], bt);

      delay(50);

    }

    analogWrite(led_pin[i], 0);

  }

}

沒有留言:

張貼留言

algorithm

 #include <iostream> #include <string.h> using namespace std; int main(int argc, char** argv)  { for(int j=2;j<=100;j++)//j...