Back to Projects
BeginnerArduino Uno R3
20 minutes build
RGB mood lamp
Blend red, green and blue with PWM for any colour.
Interactive Simulation
RGB colour mixerarduino-uno
Required Components Checklist
Assembly Steps
1
One resistor per colour
Pins 9, 10 and 11 each through 220 Ω to R, G and B. The long common leg goes to GND.
2
Mix colours
analogWrite each channel 0–255. (255, 0, 255) is magenta; (255, 160, 0) is orange.
3
Animate
Cross-fade between colours in loops.
Arduino Sketch
const int R = 9, G = 10, B = 11;
void color(int r, int g, int b) {
analogWrite(R, r);
analogWrite(G, g);
analogWrite(B, b);
}
void setup() {
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
}
void loop() {
for (int i = 0; i < 255; i += 5) { color(255 - i, i, 0); delay(30); } // red → green
for (int i = 0; i < 255; i += 5) { color(0, 255 - i, i); delay(30); } // green → blue
for (int i = 0; i < 255; i += 5) { color(i, 0, 255 - i); delay(30); } // blue → red
}
Challenges & Extensions
Ready to take this project further? Try these challenges:
- •Pick colours with three potentiometers.
- •Add a button that cycles through favourite colours.
- •Make a 'breathing' mode.