P_R_Ultrasonic
The above stack is all you need for P_R_ Touch Ultra
If you have two stacks that ask the robot to do two different things that it cannot do at the same time, you may want to use a CONTROL block that says "stop other stacks". That way, the robot knows to run that one stack and not the other -- which would cause an error, and would not work.
Note the use of the ultrasonic SENSOR block. It says to "wait" until it senses something less than < 6 cm away.
In this case, "wait" does NOT means "stand still". It means to continue doing whatever you were doing (while you are waiting). Well, what is it you are waiting for? You are waiting for a specific condition to be met before moving on to the next command.
In this stack, the first light blue sensor block says to wait until the sensor senses something less than 6cm away before stopping.
NOTE!! Do not ask the robot to detect any distances less than 4cm. Our sensors are not that sensitive and those distances WILL NOT WORK!
DO NOT use "=" . It does NOT work well. Use "greater than" (>) and "less than". If you tell the robot to stop at <15 cm from an object, it will virtually stop at 15cm. It will stop at 14.999 or anything less than that, so it is about the same as telling it to stop at 15cm. Or, you could even tell it to stop at <15.1.
Look at the second stack. It uses a "forever" LOOP CONTROL block.
The "forever" LOOP CONTROL block will cause the robot to repeat the commands within the block over and over forever.
You know it is a loop because there is an arrow at the bottom pointing back up tot he top of the block.
The second stack also uses a "conditional" CONTROL block that uses "if" and "then"
This type of conditional CONTROL only runs the following command IF the described condition is met. In this case the condition is "distance [from sensor] is [less than] 15 cm". The robot will only play the beep if there is something less than 15 cm away from it.
Your tasks:
PR Touch Ultrasonic
Robot forward when touch sensor is pressed
Robot stops when it is 15cm from the wall
Wait 1 second
Robot backs up until it is 25cm from the wall (so backs up 10cm)
P_R_My Ultra
START POSITION: Robot starts facing the wall, any distance within 10 cm.
Robot backs up until it is 28 cm from the wall and stops **you MUST use your ultrasonic sensor for this**
wait 1 sec
Robot turns 90 degrees to the left
wait 1 sec
Robot backs up 10 cm **you will not be able to use your ultrasonic sensor for this **
wait 1 sec
Robot turns 90 degrees to the right
wait 1 sec
Robot moves forward until it is 10 cm from the wall **you MUST use your ultrasonic sensor for this**
P_R_ Wall Ultra
Robot can be placed any random distance greater than (>) 15cm from the wall of your workstation.
Robot moves forward until it is 15cm from the wall
Robot waits in place 1 second.
Robot moves backward until it is 20cm from the wall.
If finished:
P_R_ Keep Distance
Program your robot to stay 15cm from your hand.
If you move your hand closer, your robot backs away.
If you move your hand farther away, your robot follows it.