MINDSTORMS EV3 Core Set

Switch

Use the Switch block to make dynamic sensor-based decisions.

90-120 min.
Intermed.
Year 5 to 8
switch-connect

Build It 

Build the Driving Base model and the Color Sensor Down Module.

ev3-robot-driving-base
ev3-robot-color-sensor-down

Test It

Recreate the program shown, then download and run to test. 
 
 
Hint
The Port View App on the EV3 Brick can also be used to view real-time sensor readings.

Switch_main

Program Summary
 
Start 
Move Steering – Degrees[685], Steering[100]
Wait – Time[1s]
Move Steering – Degrees[1380], Steering[50]
Wait – Time[1s]
Move Steering – Rotations[2], Steering[25]

Setting a Threshold

A threshold sets the upper and lower limits of a sensor and uses them to find the average, which then becomes the threshold. On the following pages, you will set the threshold of the Color Sensor’s sensitivity to light.

switch-exp1

First, make sure the Driving Base is connected via USB and then move the Color Sensor over the dark line.

switch-exp2

Next, open the Hardware Page and note down the value shown on Port 3. This is the minimum value (x).

switch-exp3

Now move the Color Sensor away from the dark line.

switch-exp4

Note down the new value shown on Port 3. This is the maximum value (y).

switch-exp5

To set the threshold, calculate the equation (x+y)/2 and enter the result in the Wait block (your value may differ from the example shown).

switch-exp6

Next, download the program.

switch-exp7

Modify It

Now it’s your turn! Test if your Driving Base works when following a lighter-colored line! If not, try setting the threshold again.

Troubleshooting
At some point, the sensor light reflecting off the line will exceed the threshold, causing the Driving Base to drive in a circle. If this occurs, change the threshold Value.

Hint
If the difference between the x and y values is too small, the line will not be detected. If this occurs, try recalibrating the sensor.

What is next? 

ModifyIt_0

Teacher Support

Students will:
Use the Move Steering block to steer the Driving Base.