2021年8月17日 星期二

color +1

 int rled_pin=9;

int gled_pin=10;

int bled_pin=11;

int btn1=2;

int num_val;

int num=-1;

void setup()

{

  pinMode(btn1,INPUT);

}


void loop() 

{

  num_val=digitalRead(btn1);

  if(num_val==LOW)

  {

    delay(1000);

    while(digitalRead(btn1)==LOW);

    num++;

    if(num==3)

     num==0;

  }

  if(num==0)

  {

    analogWrite(rled_pin,255);

    analogWrite(gled_pin,0);

    analogWrite(bled_pin,0);

  }

  else if(num==1)

  {

    analogWrite(rled_pin,0);

    analogWrite(gled_pin,255);

    analogWrite(bled_pin,0);

  }

  else if(num==2)

  {

    analogWrite(rled_pin,0);

    analogWrite(gled_pin,0);

    analogWrite(bled_pin,255);

  }

}

沒有留言:

張貼留言

algorithm

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