Intermediate
โปรเจกต์ ควบคุม rgb sensor led
สนุกไปกับ colors และ code
สนุกไปกับ colors และ code
int redPin= 11;
int greenPin = 10;
int bluePin = 9 ;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
setColor(255, 0, 0); // สีแดง
delay(1000);
setColor(0, 255, 0); // สีเขียว
delay(1000);
setColor(0, 0, 255); // สีน้ำเงิน
delay(1000);
setColor(255, 255, 255); // สีขาว
delay(1000);
setColor(170, 0, 255); // สีม่วง
delay(1000);
setColor(255,255,0);
delay(1000);
setColor(128,0,128);
delay(1000);
setColor(64,224,208);
delay(1000);
setColor(0,128,128);
delay(1000);
setColor(128,0,0);
delay(1000);
setColor(0,0,128);
delay(1000);
}
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);
}
สนับสนุนเพื่อรับ Source Code หรือแอปพลิเคชันสำหรับโปรเจกต์นี้