মূল বিষয়বস্তুতে যান
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
Open in Lab
UNOATmega328P: The 8-bit AVR microcontroller that runs your sketch (16 MHz, 32 KB flash, 2 KB RAM).ATmega328PUSB-B: USB connection for uploading sketches and for the Serial Monitor. Also powers the board (5 V).DC jack: Barrel jack for 7–12 V from a battery pack or adapter (centre positive).ATmega16U2: Converts USB to serial for uploads and Serial.print().RESET: Restarts your sketch from the beginning (setup() runs again).L (D13): Built-in LED connected to pin 13 (LED_BUILTIN).ON: Power indicator.5 V regulator: Turns 7–12 V from VIN/jack into a steady 5 V.16 MHz: Clock source: the microcontroller runs 16 million cycles per second.ICSP: In-circuit programming header (SPI). Used to burn a bootloader; not needed for normal uploads.R − G B220 Ω220 Ω220 Ω

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.