Mini Challenge 1: Threshold Value
The Wait - Ultrasonic Sensor Block uses a "Threshold" to define what it is waiting for.
Rather than look for a specific value (like 1cm or 200cm), it sets a "cutoff" value that
divides all the possible Ultrasonic Sensor
values into two categories:
This way, the Wait Block does not have to worry about the difference between an object
at 29cm and an object at 30cm; it only has to worry about about whether the value is
above or below the Threshold.
Change the Wait Block's Threshold value so that the alarm only sounds
if someone passes within 10cm of the sensor, then change it again so that it
will go off if anyone comes within 100cm of the sensor.
In both cases, the Wait Block will simply "wait for" a value below the Threshold - you just need to change what that cutoff distance is!
Pause for a couple of seconds after commands for consistency.
Missing Object Alarm (Wait for Far)
What does the Wait Block do if you set it to wait for a value Greater Than the Threshold instead of Less Than? Change the Wait Block's "Compare Type" setting to Greater Than (2).
Place an object in front of the robot, and download and run the program. Now, try moving the object and see what happens.
The Wait Block is waiting for an Ultrasonic Value "Greater Than" the Threshold before playing the sound. When the object is removed, the Ultrasonic Sensor's value jumps up because the closest object it can see is now the wall. Since the wall is more than ("greater than") 50 cm away, the Wait Block stops waiting, and the Sound Block plays! |
Did you know?
How the Ultrasonic Sensor Works
The Ultrasonic Sensor uses the speed that sound waves travels to measure distance to an object. |
Sound Sentences
You can have multiple sounds play one after another to form sentences. Try adding a second Sound Block to your program so it says "Object Detected" instead of just "Hello"!
"Object" and "Detected" can be found as separate sound files in the "Information" folder. How would you get the EV3 to say them one after another?
Place the Sound Block one after another makes them run and therefore play their sounds - in order. |
Sensor Change Mode
In addition to "Comparing" the value of the sensor against the Threshold, the Wait Block can also look at the amount the sensor value has changed since the command started.
The Wait Block ends and the alarm sounds whenever the Ultrasonic Sensor's value has changed by more than 5 centimeters from the time it started Waiting. |