Colour-Reading Glove Using APDS-9960 Sensor
by lintyl in Circuits > Raspberry Pi
271 Views, 2 Favorites, 0 Comments
Colour-Reading Glove Using APDS-9960 Sensor
A glove designed for colour-blind individuals. It detects and translates colour values into audible tones and distinct light flashes.
Supplies
Supplies Needed:
- A singular glove
- Breadboard
- Raspberry Pi Pico 2W
- Complete code is attached
- APDS-9960
- External Speaker
- Neopixel Light Strip
- Pin-to-Pin Jumper Wires
- Relevant connector(s)
- Some cardboard scraps
- Some good old tape, Velcro, and nuts + bolts
- Micro USB Cable (must be capable of data transfer)
- Power Source (optional)
Downloads
Import Modules and Install Packages
Go to PyCharm Settings and under the Interpreter menu, add any necessary packages. Use the Circup terminal command to install.
Set Up Neopixel Strip
Hardware Connections:
- Signal to GP16
- Ground to G
- Power to 5V
CircuitPython Set Up:
Set Up External Speaker
Hardware Connections:
- Signal to GP0
- Ground to G
- Power to 3V
CircuitPython Set Up:
Set Up APDS-9960
Hardware Connections:
- SDA to GP4
- SCL to GP5
- Ground to G
- Power to 3V
CircuitPython Set Up:
Set Up Definitions
Set up the 'play_tone()' function that makes your external speaker play a tone (beep) at a specific frequency (pitch) for a specific duration (length of time).
Set up the 'clear_pixels()' function that turns off all LEDs on your Neopixel strip.
Set up the 'speak()' function that looks up a tone based on the detected label (ie. “light” or “red-ish”) and plays the corresponding beep sound for feedback.
Set up the 'brightness_pattern()' function that uses different NeoPixel light animations (fast white flashes or slow blue pulses) to visually show whether the scanned object is classified as “light” or “dark.”
Set up the 'contrast_pattern()' function that displays a bold flashing pattern for high contrast or a soft steady glow for low contrast to visually indicate the contrast level detected by the sensor.
Set up the 'color_family_pattern()' function that lights the NeoPixel strip in a solid color matching the detected color family (like red-ish or blue-ish) to give clear visual feedback.
Define Colour Groupings
The program compares the red (R), green (G), and blue (B) values from the APDS-9960 sensor to determine which color family the scanned object belongs to.
- Check for invalid or initialization readings: If both R and G are zero (common during sensor warm-up), the code forces the reading to “neutral” so the system does not accidentally classify garbage data as a color.
- Calculate how similar Red (R) and Green (G) are: A 0 means R and G are almost identical. Higher numbers mean that they differ a lot. This helps distinguish yellow (where R and G are similar) from red or green.
- Classify Yellow (Y) first: Yellow is defined as where R and G are both strong, R and G are relatively similar, and both are much stronger than B.
- Classify the primary colours next: Colour is defined as 'Red-ish' if R > G and R > B, 'Green-ish' if G > R and G > B, and 'Blue-ish' if B > R and B > G.
- Classify everything else as Neutral: If none of the above conditions match (e.g., grays, browns, blacks, low saturation colors), then the result is 'neutral'.
Full Code for Colour Groupings Below:
Executing and Testing
This section prints the sensor readings for debugging, plays the corresponding audio tones for brightness/contrast/colour, and shows matching NeoPixel light patterns before pausing briefly for the next scan.
Run the code to test and calibrate colour groups if needed.
Putting the Hardware Together
Gather all your hardware and material components and get ready to put everything together!
- Use the Velcro to mount the breadboard and external speaker to the back side of the glove. Secure with some tape or additional Velcro if needed.
- Lay flat and mount the Neopixel light strip to a cardboard scrap using Velcro. Secure with some tape or additional Velcro if needed.
- Position the APDS-9960 sensor on the palm side of the glove and use nuts and bolts to secure it tightly.
- Connect the Raspberry Pi Pico 2W to a power source and run your code!
Enjoy and Re-Calibrate More If Necessary
Here's a video demo attached of how the glove should work! Re-calibrate your classification groupings as needed for your samples.
Additional Enhancement to Consider:
- Record audio that says "Light", "Dark", "High Contrast", "Low Contrast", "Red-ish", "Green-ish", "Blue-ish", and "Yellow-ish", and play it in place of the tones. You may record these audio files and convert them to .wav files using Audacity.
- Build a housing unit for the hardware components that are mounted on the back of the glove. Think of better wire management techniques so it doesn't look like you have a bomb strapped to your hand!