Activity: Survey Bot
Program the rover to perform a distance survey of the area around it. Have the rover turn on the spot and print out the value of one of the IR distance sensors at intervals around the circle.
Relevant Coding Skills
Relevant Rover Concepts
Setup
The IR distance sensors have a maximum range of approximately 125cm. If nothing is detected an IR sensor it will read 255.0cm. Place the rover amongst a collection of objects, run the code, and see if a partner can say where the objects were by only reading the distances the robot prints out. This can be done faster by using both IR sensors and only turning 180 degrees.
Here’s Our Approach
Stage 1
In our approach, our objective is to get 15 readings from the environment around us. You might use a different number of readings. We will start with a loop block that repeats 15 times. If you’re missing obstacles, try a higher number to collect more readings.
Stage 2
We will need a motor turn by degrees block inside our loop. If we want our robot to have turned a full 360 degree circle once the code has finished running, this block will need to turn one fifteenth of a circle each iteration. After it has run 15 times our rover will have turned a full 360 degrees. We can use a math operation block to divide 360 by 15.
Stage 3
Finally we need the rover to print out the IR distance values. The print block will print that IR value to the console.