Versione italiana (english version below)
Rieccomi qui, per mostrarvi come realizzare una “color mixing lamp”: una lampadina che cambia colore.
Il progetto è molto semplice, così come il materiale necessario:
- un LED RGB;
- tre resistenze da 220Ω;
- cavi di connessione
Basta collegare il LED al GND e all’Arduino tramite le resistenze. Questo lo schema del circuito:
LED RGB
Questo particolare LED è dotato di 4 pin: tre per i rispettivi colori primari rosso, verde e blu, e il quarto è il catodo. Creando una differenza di voltaggio sui pin (connessi all’Arduino tramite resistenze da 220Ω), il LED oscillerà tra i tre colori. Il piede più lungo è l’anodo.
Pulse Width Modulation
Il LED RGB ovviamente può mostrare più dei tre colori primari: basta modificare il voltaggio applicato ai pin (il valore dei colori varia da 0 a 255).
Per far ciò, viene utilizzata la tecnica Pulse Width Modulation, o PWM. E’ un procedimento che consiste nel cambiare molto rapidamente l’output sul pin da HIGH a LOW, per un certo periodo di tempo. E’ molto simile al funzionamento dei film: una serie di immagine scorre molto rapidamente, creando l’illusione del movimento.
La percentuale di tempo in cui il pin è su valore HIGH si chiama duty cicle. Più è alto il valore del duty cicle, più è alto il voltaggio applicato sul pin, e, di conseguenza, il valore del colore corrispondente.
La scheda che utilizzo, Arduino Uno, è dotata di sei pin predisposti al PWM (pin digitali 3, 5, 6, 9, 10 e 11), che possono essere identificati dalla tilde ~ posta vicino al numero del pin sulla scheda.
Software
Utilizzeremo due programmi:
- lo sketch Arduino, che legge terne di valori nel formato (r;g;b) dalla porta seriale e illumina il led del colore inviato (ad esempio la stringa “255;0;0″ per il rosso);
- lo sketch Processing che invia tramite porta seriale la stringa con i valori rgb del colore selezionato dall’utente.
Clicca qui per scaricare il pacchetto completo.
Questo è il risultato finale:
Stay tuned!
English version
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:
RGB
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.
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:
Stay tuned!






















