Color mixing lamp


Hello guys, today we are going to learn how to build up a “color mixing lamp”: a lamp that is able to change its color.

The project is really simple, as well as the required components:

  • a RGB LED;
  • three 220Ω resistances;
  • cables

You just have to connect the LED to GND and to Arduino, through the resistances. This is the circuit:

ColorMixingLamp Circuit Scheme

RGBRGB LED LED

This particular kind of LED has 4 pins: three for the primary colors red, green and blue, and the fourth is the cathode. By creating a voltage difference between the cathode and the voltage coming out of the Arduino’s PWM pins, the LED will fade between the three colors. The longer leg is the anode.

Pulse Width Modulation

RGB LED obviously can show more than the three primary colors: you just have to modify the voltage on its pins (color value vary from 0 to 255).

For this reason, you will need the technique called Pulse Width Modulation, or PWM. It consists of rapidly turning the output pin HIGH and LOW over a fixed period of time. The change happens faster than the human eye can see. It’s similar to the way movies work, quickly flashing a number of still images to create the illusion of motion.

When you are rapidly turning the pin HIGH and LOW, it is as if you were changing the voltage. The percentage of time a pin is HIGH in a period is called duty cicle. When the pin is HIGH half of the period, the duty cicle is 50%. The higher is the duty cicle, the higher the voltage on the pin, and so is the value for the color.

Pulse Width Modulation

The board I use, Arduino Uno, provides six set aside for PWM (digital pins 3, 5, 6, 9, 10 e 11), that can be identified by the tilde ~ next to their number on the board.

Software

This project need two programs:

  • the Arduino sketch, that reads terns of value in the format (r;g;b) from the serial and lights up the led of the right color (for example, “255;0;0” means red);
  • the Processing sketch, that catch the user input and send via serial the string for the chosen color.

Click here to download the complete package.

This is the final result:

ColorMixingLamp - Finished

Stay tuned!

Lascia un commento

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...