What it shows
The TCS3200 sensor measures how much red, green and blue light an object reflects. The Arduino classifies the colour and uses a servo to drop the object into the right bin, a small model of an industrial sorting line.
The science
The TCS3200 has a grid of photodiodes with red, green, blue and clear filters; control pins S2 and S3 choose the filter. The output pin is a square wave whose frequency is proportional to the light reaching those photodiodes. The Arduino measures the pulse width with pulseIn for each of the three filters. A shorter pulse means more light of that colour, so the smallest of the three values shows the main colour once the readings are calibrated against white and black.
Materials
Cost: under Rs 1,500. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.
- An Arduino Uno or compatible board
- A TCS3200 colour sensor module with built-in LEDs
- Two SG90 servos
- A 5 V 2 A power bank for the servos
- Coloured beads or candy-coated chocolates (red, green, yellow, blue)
- Card, paper cups and a plastic tube as a hopper, chute and bins
- A breadboard, wires, a black card hood to shut out stray light
Safety
For this project: Low voltage only. Do not eat any candies used in testing. Keep fingers clear of the moving servo arm.
Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.
All the safety rulesStep by step
8 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.
Connect the sensor: VCC to 5 V, GND to GND, S0 to pin 4, S1 to pin 5, S2 to pin 6, S3 to pin 7 and OUT to pin 8; set S0 high and S1 low for 20 percent scaling.
Mount the sensor about 2 cm above the feeding spot and shield it with a black hood so room light does not change the reading.
Print red, green and blue pulse widths for each coloured bead and write them in a table.
Make a classifier: if the red value is the smallest and well below green, call it red; build similar rules for green, blue and yellow using your table.
Connect servo 1 (feeder) to pin 9 and servo 2 (chute) to pin 10, powered from the external supply with shared ground.
Program the feeder to move one bead from the hopper under the sensor and stop for 500 ms.
Classify, rotate the chute servo to the angle of that colour’s bin, and let the feeder drop the bead.
Run 20 beads, count the mistakes and improve the rules until the error is below 10 percent.
What you should see
The machine sorts beads into colour bins, with fewer than one wrong bead in ten after calibration.
Viva questions
A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.
1How does the sensor pick out one colour?
A filter in front of the photodiodes passes only red, green or blue light at a time.
2Why does a smaller pulse width mean more light?
The sensor output frequency rises with light, so the period is shorter.
3Why shield the sensor?
Changing room light changes the readings and causes mistakes.
4How could the sorting be made more reliable?
Average several readings and recalibrate against white paper regularly.
Take it further
Add an LCD counter that shows how many beads of each colour were sorted.
Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.
Free ebooks for this project
Robotics
Robotics and Electronics Basics Study Book
The complete study notes, practice questions and glossary for Robotics and Electronics Basics
