Colour identifier for colour-blind users
Build it step by step
0 of 7 doneTest the sensor
Print raw red, green, blue and clear.
Calibrate on white paper
Store the white reference.
Print scaled values
Try coloured cloth.
Update the colour table
Use your own swatches.
Find the nearest colour
Print its name.
Add the voice
Play the name from the SD card.
Mount it
Fix the sensor in a small case with a shaded nose.
How do you build a colour identifier for colour-blind users?
Hold a sensor against clothing and it says the colour name aloud. You need Arduino Nano, TCS34725 colour sensor, DFPlayer Mini MP3 module, Speaker 8 Ω 0.5 W, SanDisk microSD card 32 GB (A1, Class 10), Tactile push button 6 mm and Resistor 1 kΩ. It takes 7 steps and about 120 minutes.
- Level
- Beginner
- Time
- About 120 min
- Parts
- 7
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- InterfacesBuy
- Motors & ActuatorsBuy
- SBC AccessoriesBuy
- SwitchesBuy
- PassivesBuyResistor 1 kΩ × 1
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| TCS34725 VIN and GND | Nano 5V and GND | Power |
| TCS34725 SDA and SCL | Nano A4 and A5 | I2C |
| Read button | Nano D2 and GND | Read the colour |
| DFPlayer TX | Nano D10 | Replies |
| DFPlayer RX | Nano D11 through a 1 kΩ resistor | Commands |
| DFPlayer SPK1 and SPK2 | Speaker | Voice |
| USB or battery pack | Nano | Power |
Code
The sensor measures red, green and blue light reflected from the cloth under its own white LED. Pressing and holding the button for 1.5 seconds with the sensor on white paper stores the calibration, which cancels the sensor's own colour bias. After that each press reads the colour and picks the nearest one from a list of twelve reference colours, then plays that name from the SD card. The reference values here are only a starting guess: put swatches of your own cloth in front of the sensor, print what it reads, and update the table, since fabrics and lighting differ. It names broad colours and cannot tell patterns or shades in detail, so it is an aid and not a replacement for asking someone. Keep the sensor at a steady distance of about 1 cm from the cloth, and shade it from daylight. Record the names yourself as short MP3 files on a FAT32 card. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Colour identifier. Libraries: Adafruit TCS34725, DFRobotDFPlayerMini. Board: Arduino Nano.
// SD card tracks 0001 to 0012 in this order: red, orange, yellow, green, blue, purple, pink, brown, black, white, grey, beige.
// Hold the sensor 1 cm from the cloth with the board's white LED on. First press with the sensor on white paper to calibrate.
#include <Wire.h>
#include <Adafruit_TCS34725.h>
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
Adafruit_TCS34725 tcs(TCS34725_INTEGRATIONTIME_154MS, TCS34725_GAIN_4X);
SoftwareSerial mp3(10, 11);
DFRobotDFPlayerMini player;
const int BTN = 2;
float whiteR = 1, whiteG = 1, whiteB = 1, whiteC = 1; // calibration on white paper
// Reference colours as red, green, blue on a 0 to 255 scale (a starting guess, adjust with your own cloth samples)
const byte REF[12][3] = {{200,30,30},{230,120,30},{230,210,40},{40,160,60},{40,70,200},{120,50,150},{240,130,170},{110,70,40},{20,20,20},{240,240,240},{128,128,128},{220,200,170}};
void setup() {
pinMode(BTN, INPUT_PULLUP);
tcs.begin();
mp3.begin(9600); player.begin(mp3); player.volume(22);
}
void readRGB(float& r, float& g, float& b, float& c) { uint16_t R, G, B, C; tcs.getRawData(&R, &G, &B, &C); r = R; g = G; b = B; c = C; }
void loop() {
if (digitalRead(BTN)) return;
delay(300);
if (!digitalRead(BTN)) { // held for 1.5 s: calibrate on white paper
unsigned long t0 = millis();
while (!digitalRead(BTN) && millis() - t0 < 1500) {}
if (!digitalRead(BTN)) { readRGB(whiteR, whiteG, whiteB, whiteC); player.play(10); while (!digitalRead(BTN)) {} return; }
}
float r, g, b, c; readRGB(r, g, b, c);
r = constrain(255.0 * r / whiteR, 0, 255); g = constrain(255.0 * g / whiteG, 0, 255); b = constrain(255.0 * b / whiteB, 0, 255);
int best = 0; float bestD = 1e9;
for (int i = 0; i < 12; i++) {
float d = sq(r - REF[i][0]) + sq(g - REF[i][1]) + sq(b - REF[i][2]);
if (d < bestD) { bestD = d; best = i; }
}
player.play(best + 1); // say the closest colour
delay(1500);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| White paper | Says white |
| A red shirt | Says red |
| A navy shirt | Says blue or black |
| Different room light | Recalibrate and it still works |
If it does not work
Always the same colour
Recalibrate on white and check the distance.
Wrong names
Update the reference table with your own samples.
No voice
Check the SD card format and the file names.
Reads too dark
Move closer and make sure the LED is on.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the colour identifier for colour-blind users?
Arduino Nano, TCS34725 colour sensor, DFPlayer Mini MP3 module, Speaker 8 Ω 0.5 W, SanDisk microSD card 32 GB (A1, Class 10), Tactile push button 6 mm and Resistor 1 kΩ.
How long does the colour identifier for colour-blind users take to build?
About 120 minutes for a beginner maker, in 7 steps.
How do I know the colour identifier for colour-blind users works?
White paper: Says white. A red shirt: Says red. A navy shirt: Says blue or black.
Always the same colour: what should I check?
Recalibrate on white and check the distance.
Wrong names: what should I check?
Update the reference table with your own samples.
No voice: what should I check?
Check the SD card format and the file names.
Reads too dark: what should I check?
Move closer and make sure the LED is on.
