2022年2月11日 星期五

pwm 4個pulse

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

int i;

void setup()

{


}


void loop()

{

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

  {

    for ( i = 0; i < 255; i += 5)

    {

      analogWrite(led_pin[j], i); delay(30);

    }

    for (i = 255; i > 0; i -= 5)

    {

      analogWrite(led_pin[j], i); delay(30);

    }

    analogWrite(led_pin[j],i); delay(30);

    delay(100);

  }

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

  {

    for ( i = 0; i < 255; i += 5)

    {

      analogWrite(led_pin[j], i); delay(30);

    }

    for (i = 255; i > 0; i -= 5)

    {

      analogWrite(led_pin[j], i); delay(30);

    }

    analogWrite(led_pin[j],i); delay(30);

    delay(100);

  }

}

沒有留言:

張貼留言

algorithm

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