Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Arduino color sensor used in hospitals

By Usman ali Butt February 26, 2021

This tutorial is about interfacing color sensors with Arduino. We will design an autonomous patient movement system in hospitals. The color sensor which I am going to use in the project is Adafruit TCS34725. Adafruit provided predefined Arduino libraries for this sensor. It consumes 3.3v to 5v and outputs data on the I2C interface.

Color bands are stuck on the hospital floor. The bands start from the hospital entrance and lead to a specific department (emergency etc.) or ward.

The idea is to make a DIY autonomous robot (wheelchair, bed, etc.) that can take a patient from the desired ward entrance. Upon entrance, the patient can be laid on the bed and placed on the color strip, and taken to the ward.

To achieve the above functionally, we have to overcome few constraints:

  • How to turn?
  • What if the sensor goes out off the strip?

There are many ways in which the above task can be achieved using a color sensor.

Using multiple color sensors:

Multiple color sensors apart from each other cover a big area, so if one sensor moves out of the strip, others can cover the strip.

Single color sensor:

A single-color sensor, when it goes out of the strip, is impossible to retract. It needs the wheelchair motors to reverse.

Turning

Turns are hard to predict using color sensors. One way to take a turn is reducing speed and first moving a little left and see if we are in color range. If not moving a little right and repeat the process until we are aligned again.

Another way is to stick a small piece of another color strip on the main strip’s sides.

On the sides of the main red strip, small strips are also attached. When the sensor reaches the blue small strip it turns slightly right, and when orange, it turns slightly left. In this way, we can even take sharp turns.

Ultrasonic sensor

If any obstacle is ahead, we want our platform to stop. The best solution is to attach an ultrasonic sensor in front of the platform so if it detects any obstacle, it immediately stops.

Our system will behave like a rover. Four dc motors are driving platforms. Motors moving in the direction of the color strip. The color sensor takes control of motor movement decisions.

Circuit diagram

Four dc motors are connected to digital pins (10,11,12,13) of Arduino. An external motor driver drives motors. External motor driver has voltage and current regulator, which fulfills the power requirement of motors.  Flywheel diodes on the motor driver protect Arduino core from back EMF.

The color sensor is attached to analog pins (A4 and A5) of Arduino. The sensor is powered through Arduino power output.

Project code

First, I imported the Adafruit library for the color sensor and I2C library in Arduino sketch. Then color sensor processing speed is defined. In 700ms, we will get a new reading from the sensor. The speed variable controls the motor speed. Where 0 means motor off and 255 represents max speed. In the setup function, digital pins controlling motors and color sensor is initialized.

In the main function, colors are grabbed—color sensors output color in RGB (Red, Green, and Blue) values. We have to build a system which knows the exact color manually. Each R, B, and G is 8-bit color. So total colors represented are 256*256*256=16777216.

To know exactly each color, we must train our system. Represent RBG vectors in Arduino and compare them with the sensor output. It’s a tedious task, and above all, we can’t represent all the colors 16777216. The range of color codes can be grouped, and decisions can be made based on groups.

In the above code, I am making decisions based on color temperature. Adafruit color sensors can also monitor the temperature of the color. Each color has a different temperature.

The above diagram shows the temperature of the colors. In Arduino sketch temperature of color is continuously monitored. If any change is found, adjustments are made by moving the platform left and right.

Note: The above project prototype requires a lot of training. Although much better solutions are available in the market. We learned how we could achieve this task using a color sensor.

Let’s DIY the project: Where to purchase parts? 

Adafruit color sensor: Mouser
Arduino: Mouser electronics
Vehicle development platform: DigiKey
Motor driver: Mouser electronics

You may also like:


  • Wireless distance measurement using ultrasonic sensor

  • Bistatic ultrasound radar system

  • Ultrasound Imaging or Ultrasonography

Filed Under: Arduino Projects, Microcontroller Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Multiple DC/DC converters and a single input source
  • Xiaomi Mijia 1C Robot problem of going backwards while working
  • Will this TL084C based current clamp circuit work?
  • ADS optimization cockpit window does not open
  • Voltage mode pushpull is a nonsense SMPS?

RSS Electro-Tech-Online.com Discussions

  • Parts required for a personal project
  • Curved lines in PCB design
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz
  • using a RTC in SF basic
  • PIC KIT 3 not able to program dsPIC

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection
  • Convection-cooled power controller integrates EtherCat connectivity

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe