What the “Wait For Ultrasonic And Touch Sensor” brick does
![]() | The sensor will wait until either the Ultrasonic sensor has detected the selected range, or until the touch sensor is pushed. It will return the value 1 if the Ultrasonic sensor has detected the selected range, it will return the value 2 if the touch sensor was pushed, and it will return 3 if both events happened together. |
Configuring the brick
- You need to provide the ports to which the touch sensor and the ultrasonic sensor are connected.
- For the ultrasonic connector, you must also specify the trigger point. This is the distance that the ultrasonic sensor is responding to.
- If you want the ultrasonic to trigger when it comes too close to an obstacle, check the "Trigger If Closer Than Trigger Point" box. When this box is unchecked, the ultrasonic sensor will fire when there is no obstacle between the robot and the trigger point distance.
Sample Application
In this sample application, the robot has an ultrasonic sensor at the front, and a bumper at the back.
This application will drive forward until the ultrasonic sensor detects an obstacle closer than 30 cm. When that happens, it will drive backward and turn until the obstacle is further than 50 cm, or until it bumps into something with the rear bumper. Then it will start to drive forward again.
With this simple program, the robot can navigate the room and avoid obstacles and walls.
Sample Application 2
In this second sample application, we'll make things a little bit more complicated. This time, the bumper and the ultrasonic sensor are both at the front of the robot. When the bumper is pushed, then some obstacle did not get properly detected by the ultrasonic sensor.We want the robot to drive forward. When the ultrasonic sensor sees an object, then it should simply turn a number of degrees to avoid the obstacle. But if something hits the bumper, it may be blocking the robot. The robot may not be able to turn. Therefore, the robot should first drive backward, and then turn. Here's the program that does this:

Here's the setting of the switch (if-then) statement:

Notice that I have set the second option as the default option. That means that if both the ultrasonic and touch sensor fire at the same time, then we will respond to the bumper and ignore the ultrasonic sensor.






This figure shows a single pulley with a weight on one end of the rope. The other end is held by a person who must apply a force to keep the weight hanging in the air (in equilibrium).
In the second figure, the pulley is moveable. As the rope is pulled up, it can also move up. The weight is attached to this moveable pulley. Now the weight is supported by both the rope end attached to the upper bar and the end held by the person! Each side of the rope is supporting the weight, so each side carries only half the weight (2 upward tensions are equal and opposite to the downward weight, so each tension is equal to 1/2 the weight). So the force needed to hold up the pulley in this example is 1/2 the weight! The mechanical advantage of this system is 2; it is the weight (output force) divided by 1/2 the weight (input force).
Here there are 3 sections
This figure has the same two pulleys, but the rope is applied differently and it is pulled upwards. The mechanical advantage is 3, and the force to hold the weight in equilibrium is 1/3 the weight. 












































