In this tutorial based article, we are going to learn how to make an Arduino colour sorting machine.

Hardware Required

Software required 

Assembling the structure 

  •  Make a box by using a corrugated sheet.

  •  Cut the box as it is shown in the picture below.

  • Then put the servo motor in the box.

  • The servo motor has three pins connected.

  • First  Pin is red and second pin is brown and the third pin is of orange colour.

  • Attach the slide as shown in the picture below.

TCS230 Colour sensor

  • TCS230 is a colour sensor and can sense particular colours only. It can be used extensively in colour matching projects, colour sorting, test strip reading and much more. It senses the colour based on the RGB (red, green, blue) values.

  • When the R is maximum, that means we have a red object.

  • When the G is maximum, that means we have a green object.

  • When the B value is maximum, that means we have a blue object. 

  • This way it can sense which colour is put in front of the sensor 

Circuit Diagram

  • Connect the TSC3200 Sensor as bellow:

  •   S0 ==> Nano pin D2

  •   S1 ==> Nano pin D3

  •   S2 ==> Nano pin D4

  •   S3 ==> Nano pin D5

  •   OUT ==> Nano Pin D6

  •   OE ==> NonUsed

  •   VCC ==> +5V

  •   GND ==> GND

  • Connect servo GND pin to Arduino nano  GND pin.

  • Connect servo +Vcc pin to Arduino nano +5V pin.

  • Connect servo motor 1 Green pin(signal pin) to Arduino nano digital pin no.D7

  • Connect servo motor 2 Orange pin(signal pin) to Arduino nano digital pin no.D8

  • Connect the servo as follows

  • Connect both the red wire of servo to 5V in Arduino Nano and both the black wires to GND.

  • Connect both the signal pins of the servo to pins D7 and D8 respectively.

The working concept of the colour sorting machine

  • This machine works in two parts: colour sensing and colour sorting. 

  • Firstly, the colour sensor senses what colour the object in front of it is. Then this data is sent back to the Arduino Nano in front of electronics signals. This is the colour sensing part

  • The Arduino understands the signals and makes use of that data.

  • With the help of the Arduino code, we can command the servo to rotate differently for a different colour. This is how the colour sorting is done.

  • So when the Arduino receives the data about the colour, it commands the servo to rotate accordingly.

Arduino code


  • Install the required libraries. Upload the code.

  • Power up the Arduino Nano using the power supply.

Now your colour sorting machine is ready to use. Enjoy!