LEGO Robotics Light Color Sensor Background The Mindstorms

LEGO Robotics Light / Color Sensor

Background • The Mindstorms EV 3 Light and Color sensor is used to detect the color of an object and the intensity of a light source. • The Color Sensor can detect the color of a surface (Color Mode), the amount of light reflected by a surface (Reflected Intensity Mode), or the brightness of ambient light (Ambient Light Intensity Mode). • You can use the Light / Color Sensor to detect the color of a surface, follow lines or respond to light signals.

Connecting the Color / Light Sensor • When connecting the Color / Light Sensor to your robot be sure to point it in the correct direction, which is usually downward. • The sensor should be approximately 1 cm (0. 4 inches) away from the surface.

Color Mode

Color Sensor • The Color Sensor can detect the color of a surface (Color Mode). • The Color Sensor can distinguish between eight different colors, black (1), blue (2), green (3), yellow (4), red (5), white (6) and brown (7).

Test Color • • Go to the Port View app to see the Sensor Measurement. Navigate to the correct sensor input port and press the Center button. Select Col-Color and press Center again. You should see a number between 0 and 7 which represents the color. • black (1), blue (2), green (3), yellow (4), red (5), white (6) and brown (7)

Follow a Line • In this example, we wan to use the Color Sensor to follow a Black Line. • When the robot is following a black line on a white mat, the sensor will always detect either a black or white color. • The goal is to ensure that the robot always stays on only one of the black line (right side). • This can be achieved by driving the robot to the right when it detects black and driving the robot to the left when it detects white. • By making the robot drive forward a short distance as it steers and repeating this behavior indefinitely, the robot will follow the line. • Code for this example is provided on the following slide.

Follow a Line • This program for Follow the Line uses the following components: • Color Sensor that controls a Switch Block (Black – True / White - False) • Switch Block to trigger Move Steering Block (True – Turn Right / False – Turn Left)

Reflected Light Mode

Reflected Light Mode • The Color Sensor can also measure the brightness of a color in Reflected Light Intensity mode. In other words, the Color Sensor can distinguish the difference between white, black and various shades of grey based on the amount of light that is reflected. • 0 % Reflected Light Intensity would be Dark or Black • 100 % Reflected Light Intensity would be Light or White • In between these two would be various shades of grey. Higher numbers equal brighter colors and lower numbers equal darker colors

Reflected Light Intensity Functionality A light sensor uses thresholds to divide the values that it receives into categories of “light” and “dark, ” much like the Sound Sensor divides values into “loud” and “quiet. ” Light Sensor is over dark light surface line

Ambient Light Intensity Mode

Ambient Light Intensity Mode • The Color Sensor can be used to detect the light level in a room or the brightness of a light source using the Ambient Light Intensity mode. • You can measure ambient light intensity capability in a program in a similar manner as was used to measure reflected light. To do this you will use the Color Sensor – Compare – Ambient Light Intensity mode. • Using the Ambient Light Intensity mode, you can detect whether the lights in a room are on. To do this you could use a Switch Block to test whether the sensor value is greater than the threshold value.

Ambient Light Intensity Mode (continued) • To use the Ambient Light Intensity mode, you will likely need to change the way the Light Sensor is mounted. • The sensor emits a blue light in Ambient Light Intensity mode but the light actually turns off for a very short period each time it conducts a measurement. This ensures that reflected light is not measured but rather the sensor sees only the light coming from the robot’s environment.
- Slides: 14