Tip:
Highlight text to annotate it
X
Our Robot found the black line around the SUMO ring, but did not stop.
We need it to stop when it reaches the black ring.
We use the Color Sensor to get it to stop.
The color sensor can measure the light reflected from the SUMO mat.
Black reflects only a small amount of light.
We can change the EV3 screen to read the amount of reflected light
"Port View" shows the measurements from the sensors attached to EV3 ports 1, 2, 3 and 4
YayaBot has an ultrasonic sensor on port 3, and a color sensor on port 4.
When the reflected light is measured from the black surface
the color sensor measures 4% reflection
When the reflected light is measured from the white surface
the color sensor measures 72% reflection
How do we use this difference?
We use a "Switch" that does different things, depending on the color sensor light reading
Raise the orange rectangle
Left-click and drag the "Switch" to the Command line...
inside the "Loop"
Remove the "Document" widow to get more screen room
Change the Switch from a "Touch Sensor"
Left-click and choose the "Color Sensor" option
Choose the "Compare" option
and then choose the "Reflected Light Intensity" option
This will mean that the switch will use the reflected light measurement from the color sensor in slot 4
We can use six comparison options
> Greater than < less than
We will use either "Greater Than" (2) or "Greater Than or Equal to" (3)
This will mean that when the Color Sensor has a high or low reading a different part of the Command line will be used.
But greater than which color sensor value?
At the moment the "decision value" is set at 50.
To calculate the new value we use...
(4% black + 72% white)/2 = 38% (your values will be different because your room will have different light)
38% is the average of our black and white color sensor readings (your values will be different)
If YayaBot is on white (Color Sensor>38) the Commands in this top line are used
If YayaBot is on black (Color Sensor38%
It does this many times a second.
But when the light is less than 38%, the top line "Move Tank" Command is ignored, and...
the Commands on the lower line are used - but...
but we don't have any commands there.
We want YayaBot to stop when it reaches the black line (the color sensor reading is 38%) YayaBot goes forwards both motors B & C 50%
When the color sensor sees black (