This sensor enables the robot to “see” light intensity and colors. We prefer to call it Color Sensor. It can differentiate between most basic colors and thus help the robot act accordingly when it detects or does not detect your color of choice.
Attaching a Color Sensor
Please refer to pp. 68-72 of the EV 3 Manual (Building Instructions) for a Color Sensor facing downwards, and pp. 73-75 for a setup with a forward-facing sensor.
Programming: Step-by-step Instructions
Please find a printable version of these instructions HERE.
1) Forever <Loop>
Drag a Forever <Loop> from the Control Panel onto the programming canvas.
This way, the program will test for a color repeatedly.
2) <IF-THEN-ELSE> Block
The <IF-THEN-ELSE> Block determines what the robot will do when it detects a color (IF-THEN), and what to do when the color is not detected (ELSE).
Make sure to place it “inside” the <Loop> Block.
3) Color Sensor
4) Set Color and Port
Set the color you want the sensor to detect.
Here, we selected “red”.
Make sure the Port on the Sensor Block matches the Port on the robot (on the back, labelled 1-4).
Here, the Color Sensor is plugged into Port 1 and it is also shown on screen.
5) Adding Sound
Drag a <Sound> Block into the IF-THEN part.
Then, choose a sound you want the robot to play when it sees the chosen color.
We chose the sound “red”.
6) Adding Sound 2
Next, choose a sound you would like the robot to play when is does not see the color.
Add it to the ELSE part.
We chose “no”.
7) Test Your Program
8) Stop Loop on Red
To stop the robot when it detects red, select the <Stop> Block from the Controls menu.
Insert it after the sound confirming that “red” was found.
Please find a printable version of this page HERE.
© 2022 Dr. Krista Francis & Stefan Rothschuh
Recent Comments