Lego ΕV3: Eντολή Switch

EV3 Robot Educator Tutorials : Switch
Use the Switch block to make dynamic sensor-based decisions.
STEMEngineeringRoboticsTechnology
LESSON PLAN
BUILD IT

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

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.

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.

 

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

 

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

Now move the Color Sensor away from the dark line.

 

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

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).

Next, download the program.

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.

Αλλαγή μεγέθους γραμματοσειράς
Αντίθεση