Introduction: Simple RGB Color Detector Using Arduino
How do you see colors?
Light is an electromagnetic wave that is available in our universe. As human being we see only a part of the whole Electromagnetic spectrum.
Assume a red ball: When the light hits its surface, it reflects the red color (wavelength) and absorbs all other colors.
How color sensor works?
Assume we have red ball and blue one. Consider the reflected brightness comparison;
If we shined red light (e.g. red LED) and measured the reflected brightness using LDR (Light-Dependent Resistor). We will find out that the red ball will reflect more light than the blue ball.
Now if we shined blue LED, the blue ball will reflect more light than the red ball. The same concept you can do to detect green color.
Why using RGB?
The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors.
Step 1: Required Components
- LDR (Light-Dependent Resistor)
- Red LED
- Green LED
- Blue LED
- Three Resistors (330 ohm)
- One Resistor (100k ohm)
- Arduino ( I used Nano)
- Breadboard Wires and USB cord
- Black Tape and paper
Step 2: Circuit Design
The output Red LED is attached to digital pin 2, through 330 ohm resistor
The output Green LED is attached to digital pin 3, through 330 ohm resistor
The output Blue LED is attached to digital pin 4, through 330 ohm resistor
The LDR with 100k ohm resistor forms a voltage divider circuit, its output is attached to Analog input pin 0
Step 3: Breadboard Layout
Step 4: Sensor Isolation
- Isolate the LDR from the LEDs by a black paper or a black tape. Because the LDR should sense the reflected light from the object, so an isolation between the LDR and the direct LED illumination should be applied.
- Isolate the whole sensor from the surrounding lights by another black tape.
The Black color is used because it absorbs all light waves
Step 5: Download My Source Files
Download my source files ( Code and Circuit).
Step 6: Testing
The sensor is capable of distinguishing between Red-Green-Blue colors, from a distance (around 2 cm).
We have a be nice policy.
Please be positive and constructive.