Arduino Color Sensor Tutorial

Home/Uncategorized/Arduino Color Sensor Tutorial

Arduino Color Sensor Tutorial

In this video Arduino Color Sensor Tutorial we are going to see how use the TCS230 color sensor with Arduino. It is a very interesting sensor that will enable us to build some amazing projects. Without any further delay, let’s get started!

Arduino Color Sensor Tutorial – The Parts

Hey guys, I am Nick and welcome to educ8s.tv a channel that is all about DIY electronics projects with Arduino, Raspberry Pi, ESP8266 and other popular boards. In this video we are going to learn how to use the TCS230 color sensor, a very interesting sensor. I have built a simple project to demonstrate that this sensor is really capable. I use an Arduino Uno and a 1.8” Color TFT display and of course the color sensor. As you can see, the sensor detects the colors and it displays them on the screen. The color we get on the screen is pretty close to the real color of the object. Cool isn’t it? Now, let’s see the parts that we need in order to build this project.

——————–
WHERE TO BUY
——————–

Arduino Uno: http://bit.ly/Cheap_Uno

Color Sensor: http://bit.ly/ColorSensorGB

Color TFT: http://educ8s.tv/part/7735

Small Breadboard: http://bit.ly/SmallBreadboard

Jumper Wires: http://bit.ly/JumperWiresB

3 in 1 wires: http://bit.ly/Wires3InOne

Power Bank: http://bit.ly/PowerBank_XiaoMi

Full disclosure: All of the links above are affiliate links. I get a small percentage of each sale they generate. Thank you for your support!

 

Let’s now see the software side of the project. In order to use the color sensor we need two libraries. We need the TCS230 library and the Frequency library. We also need two libraries for the display. You can find links for all the libraries we use in the description of the video.

——————–
LIBRARIES
——————–

Color Sensor Library: https://github.com/Swap-File/tron-suit/tree/master/Disc/Software/Libraries/MD_TCS230

Frequency Count: https://github.com/PaulStoffregen/FreqCount

Adafruit ST7735: https://github.com/adafruit/Adafruit-ST7735-Library

Adafruit GFX: https://github.com/adafruit/Adafruit-GFX-Library

Arduino Color Sensor Tutorial – The Code

First of all we initialize the display and we display the splash screen. Next we initialize the sensor and we read the color from it. We set the first color we read as Black because first have to calibrate the sensor. Next, we read the sensor again and we set the color we read as white. After the calibration is over we read the sensor and we display the color we get on the display. Before printing the color on the display we first have to convert it to a 16bit value. The color sensor outputs a 24bit color value but our display can only display 16bit colors. That’s why we need to convert the colors before printing them with this function. With this line of code we display a small rectangle with the color we read from the sensor. As always you can find the code of the project in the description of the video below.

As you see, the color sensor is a great addition to our Arduino sensors. With this sensor available we can build many interesting projects. We can add a color sensor to a robot, or robotic arm or we can build a color sorting machine. I am really interested in a color sorting machine that will have a practical implementation. I live in Greece and many Greek farmers grow olive trees for a living. They sell either the olive oil they produce or the olives for consumption. Black olives are sold in higher prices than green olives. What if we could sort the olives by color with the help of a simple and low cost Arduino machine? That would mean better income for farmers and less time sorting the olives by hand. I will try to build a project like this in the future and post a video about it. I would love to hear your thoughts on the color sensor. What other projects do you plan to build with a sensor like this? Please post your comments or ideas below. Thanks!

——————–

CODE OF THE PROJECT
——————–

Download

 

 

 

——————–

SUBSCRIBE ON YOUTUBE

——————–

Never miss a video: Subscribe to educ8s.tv

2017-09-06T12:58:02+00:00

One Comment

  1. Tom April 2, 2017 at 9:09 am - Reply

    Hi I have run through the calibration library that comes with the TCS230 and even then the colours don’t appear vibrant they are more quite dark.. I was wondering if there’s any hints you have to getting the sensor return a more vibrant representation of the colours?

Leave A Comment

Close