Starting from:
$28

$18.20

[SOLVED] LAB: Basic Color Sensor using Atmega328p Analog to Digital Converter.

In this lab, our goal is to design a basic color sensor which is able to distinguish between Red, Yellow and Blue color objects. Items Required: 1. Breadboard 2. Color LEDs (Red, Yellow and Blue) = 03 3. Groove Light Sensor 4. Connecting Wires 5. Arduino Uno Board 6. Groove Base Shield 7. Resistors = 220 ohm x3 (For LEDs). 8. Color Balls (or other similar objects)- Red, Blue and Yellow. Operating Principal. When a color object is irradiated by a color light containing Red Green Blue component, the color intensity of reflected light will change depending upon the color of the object. For example, if an object is Red colored, and it is illuminated by Red, Green and Blue color LEDs then the intensity of reflected light in response to red LED will be greater as compared to the intensity of reflected light in response to other LEDs as shown in following figure. In this way we can design a basic color sensor which is able to sense the color of an object placed in front of LEDs and whose reflected light falls on LDR. Hardware Setup. You are required to connect three LEDs (Red, Yellow and Blue) to the GPIO pins and Light Sensor to Analog Input 0 (i.e. Pin PC0) of microcontroller. Important thing is how to place Light Sensor and LEDs on the breadboard so that the light emitted by the LEDs falls on the object only and not directly on the Light Sensor. To do so, we must isolate the Light Sensor from LEDs by using a black tape. The following setup can be a good help. Now, the object to be detected should be placed above the LEDs at a suitable distance, so that the reflected light falls on Light Sensor. (Do the rest of the wiring yourself). Software Setup You need to open Serial.begin(9600) in the setup function. In the main function you need to do the following: 1. Define output pins for LEDs 2. Declare variables of type uint16_t to store the intensity of reflected light for Red, Yellow and Blue. 3. In the while Loop:  Turn on Blue LED and wait 2 seconds.  Read ADC and store it in the registry as blue.  Turn on Yellow LED and wait 2 seconds.  Read ADC and store it in the registry as yellow.  Turn on Red in RGB LED and wait 2 seconds.  Read ADC and store it in the registry as red.  if intensity_red > intensity_yellow && intensity_red > intensity_blue Send Message ("color is red"); else if intensity_yellow > intensity_blue Send Message ("color is yellow"); else Send Message ("color is blue");