⭐ Q4. RGB LED Control
Hindi:
RGB LED के तीन रंगों को Arduino से control करना।
English:
Controlling RGB LED colors with Arduino.
🔧 Components
Arduino
RGB LED
3 × 220Ω Resistors
🔌 Connections
Red → Pin 7
Green → Pin 6
Blue → Pin 5
✅ CODE
int redPin = 7;
int greenPin = 6;
int bluePin = 5;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
setColor(255,0,0); // Red
delay(1000);
setColor(0,255,0); // Green
delay(1000);
setColor(0,0,255); // Blue
delay(1000);
setColor(255,255,255); // White
delay(1000);
}
void setColor(int r, int g, int b) {
analogWrite(redPin, r);
analogWrite(greenPin, g);
analogWrite(bluePin, b);
}
📘 Working
PWM signals का उपयोग करके colour mixing किया जाता है।