Arduino Colour Sorting Machine with TCS3200 Sensor and Servo
Build a colour sorting machine: read a sweet through the colour sensor’s red, green and blue filters, name its colour on the LCD and turn the chute to that colour’s bin.

Your project challenge
Read OUT with pulseIn(LOW) through each filter: red (S2, S3 LOW, LOW), green (HIGH, HIGH), blue (LOW, HIGH). All three over 1200 µs: Empty, servo 90°. Red and green both under 400: Yellow, 150°. Otherwise the smallest wins: Red 30°, Green 70°, Blue 110°. Show the name on the LCD.
Components you’ll use
- Arduino Uno
- Colour Sensor (TCS3200)
- SG90 Micro Servo
- LCD 16x2 Display
What you’ll build
A machine that sorts sweets by colour, like the machines that sort grains, coffee beans and recycling. A sensor looks at each sweet, and a servo turns a chute towards the right bin.
How it works
The TCS3200 shines white light on the sweet and measures what bounces back through a red, green or blue filter. You choose the filter with S2 and S3. OUT is a square wave: more light, faster wave, shorter pulses. Use the sweet buttons to place one under the sensor.
The key idea
pulseIn(8, LOW) measures how long OUT stays LOW. A red sweet sends back lots of red light, so the red pulse is the shortest. Yellow is red and green light together.
⚠ Watch out
Wait a few milliseconds after changing S2 and S3 before you measure. An empty tray is dark on every filter.
Make it yours: real sensors drift with room light. Measure a white card at start-up and divide every reading by it.
The editor has the wiring guide, the code and the simulator.
Build this project