2022年3月8日 星期二

RGB

 int r1=3;

int y1=4;

int g1=5;

int r2=6;

int y2=7;

int g2=8;

void setup(){

  pinMode(r1,OUTPUT);

  pinMode(y1,OUTPUT);

  pinMode(g1,OUTPUT);

  pinMode(r2,OUTPUT);

  pinMode(y2,OUTPUT);

  pinMode(g2,OUTPUT);

}

void loop(){

  digitalWrite(r1,1);

  digitalWrite(y1,0);

  digitalWrite(g1,0);

  digitalWrite(r2,0);

  digitalWrite(y2,0);

  digitalWrite(g2,1);

  delay(5000);

  digitalWrite(g2,0);

  delay(1000);

  digitalWrite(g2,1);

  delay(1000);

  digitalWrite(g2,0);

  delay(1000);

  digitalWrite(g2,1);

  delay(1000);

  digitalWrite(r1,1);

  digitalWrite(y1,0);

  digitalWrite(g1,0);

  digitalWrite(r2,0);

  digitalWrite(y2,1);

  digitalWrite(g2,0);

  delay(2000);

  digitalWrite(r1,0);

  digitalWrite(y1,0);

  digitalWrite(g1,1);

  digitalWrite(r2,1);

  digitalWrite(y2,0);

  digitalWrite(g2,0);

  delay(5000); 

digitalWrite(g1,0);

  delay(1000);

  digitalWrite(g1,1);

  delay(1000);

  digitalWrite(g1,0);

  delay(1000);

  digitalWrite(g1,1);

  delay(1000);

  digitalWrite(r1,0);

  digitalWrite(y1,1);

  digitalWrite(g1,0);

  digitalWrite(r2,1);

  digitalWrite(y2,0);

  digitalWrite(g2,0);

  delay(2000);

}


沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。