We’ve learned how to use the LCD module, the microphone module, LEDs and the potentiometer. Those are devices you will make use of most of the time.
Today, we are going to be working with the Arduino color sensor module. It is a quite unpopular piece but often very useful and easy to use. The color sensor can be used in projects like the skittle sorting machine.
This project will consist of letting the sensor read colors and using the LCD to display the current color the sensor is reading. The color sensor is quite hard to calibrate to get the perfect results thus we will display only the following 3 colors: the red, green and blue.
Arduino color sensor
Parts needed
While using the schematic below to connect the project, remember that if your Arduino board does not have separate SCL and SDA pins, you can connect the pins from the LCD to A4 and A5 (analog pins) of the Arduino. If you do so, remember to indicate the right pins in the code.
This code will read colors from our sensor using the pulseIn function because the TCS230 returns the frequency of each color (red, green, blue). With pulseIn, we can read colors and easily compare them to one another to identify the current color and display it on the LCD.
We will do it every half a second.
The program also prints those colors on the serial, just in case you don’t have an LCD. The only library that you need is for the LCD with I2C converter.
Here is the code:
The one thing that can be unclear in this code is this:
digitalRead(10) == HIGH ? LOW : HIGH
It’s just a short form of if and else. (if the read from pin 10 is HIGH, it will return LOW otherwise it will return HIGH). If and else in one line without brackets.
The best materials to use while testing the project are pieces of paper as we’ve done in the video below.
Hope this helped, and I will challenge you to go and create something amazing using the basic tools we have just made use of in the project.
You might also like:
- Arduino hx711 tutorial
- Arduino magnetic switch
- Best Arduino Kits
- gifts for engineering students
- gifts for engineers
- mpu6050 Arduino projects
- Current sensor Arduino
- Soil Moisture Sensor With Arduino
- Arduino Count up Timer Using the Nokia 5110 LCD
- Arduino Yun: Integrating or Juxtaposing Arduino with Linux
- Arduino Projects: Line Follower Robot
- Arduino RFID Project for Beginners
- Arduino MOSFET Project
- Which Arduino Should You Buy
- What Can You Do With Arduino Boards?
- Great Alternatives to the Arduino Microcontroller
- Arduino Projects: Color Sensor
- Arduino IDE Alternatives
- Arduino Mega vs. Uno
- Arduino Projects: Arduino LCD Display
- Read Arduino Rotary Encoders
- A Selection of the Best Arduino Simulators
- Arduino Projects: IR Receiver
- Arduino Light Sensor Project
- Arduino Projects: Arduino Decibel Meter
- Arduino Stopwatch Project
- Arduino Bluetooth RC Car Project
- Arduino Temperature Logger Project
- Arduino Projects: Arduino 7 Segment Display
- Arduino Projects: Clap ON Clap OFF Light
- Arduino Relay Project
- Install a Library Onto the Arduino IDE
- Arduino Projects: Rainfall Detector
- Arduino Projects: RGB LED Arduino
- Arduino Stepper Motor Project
- Arduino Projects: Arduino DC Motor Control
- The Top Affordable Arduino Robot Kit
- Arduino 3D Printed Case
- Arduino Projects: Asynchronous LEDs Blink
- Arduino Projects: Ultrasonic Distance Sensor
- Arduino Projects: LED – 4X4X4 LED Cube
- Arduino Car Projects: Build an Obstacle Avoiding Robot With Less Than $30
- Arduino Projects: Servo Potentiometer Control
- Arduino LED Project: Knight Rider
- Arduino Projects: PIR Motion Sensor
- The Difference between Arduino and Raspberry Pi
- Top 9 Books Every Engineer Should Read
- Top Used Sensors for Arduino
- First Hand on the Arduino Uno Board