Sorry, I'm not sure I understand the question. I'm going to assume this is
"troubleshooting task 2" from Robot Project 4?
I'm not going to post code here, because I want you to try this out yourself, but I will post an outline of some code.
Note that in
troubleshooting task 1, you are asked to
NOT use a loop. That means you just play one note or the other. If you set the duration of your notes to 5 seconds, then you will stay in the switch for 5 seconds. So no matter what happens with your sensors, you're stuck in that switch for 5 seconds.
In
troubleshooting task 2, you are asked to combine the loop and the switch.
- If you were doing this with music, and you set the duration of your note to 5 seconds, then you'd still be stuck in the switch for 5 seconds before checking what's going on with your sensors
- Similarly, if you do this with "display an image" followed by a wait for 5 seconds inside the switch, then you're stuck in the switch for 5 seconds before checking what's going on with your sensors.
- On the other hand, if you changed the duration of your note to, say, 0.25 seconds, then you'd leave the switch relatively quickly, which would mean that you'd check what's going on with your sensors relatively quickly
- Similarly, if you had a display block followed by a short wait of, say, 0.25 seconds, then you'd check what's going on with your sensors relatively quickly.
So, to answer your question. You
can indeed put a (very short) wait block inside the switch rather than outside. The important thing is that your wait block has to be for a very short duration. Otherwise it will appear that the robot is not reacting to the ultrasonic sensor.