13 |
P a g e
F. Avoid or Seek
The
Ultrasonic Sensor
is used to measure the distance between the mBot2 and anything in front of it (up to about
200cm). It can be used to avoid obstacles or seek out an object and move toward it.
The minimum distance detected is about 4cm
. Smaller distances give a reading of 300.
Test your Ultrasonic Sensor with this code. Putting all the sensor reading code into a function unclutters the main
loop.
Obstacle Avoidance