2024 Ultrasonic Robot

Now you will add an ultrasonic sensor to your robot.

Use the physical circuit and program that you built for Ultrasonic Sensor Part 2 as the brains and eyes of your robot.

Your goal is to build a two-wheel robot that can change it’s path to get around obstacles.  The ultrasonic sensor will tell the robot how close it is to an object.

In addition to the circuit that you have already built, you will need the following:
-your own cardboard mount to attach the ultrasonic sensor
-a small breadboard to mount the sensor – please glue this down – DO NOT PEEL the adhesive off.
-1 ultrasonic sensor
-4 wires for the sensor

Robot requirements:
1. your robot should turn when it encounters an obstacle.
2. after the turn is completed your robot should drive straight until it detects another obstacle.  Then it will repeat step 1.

Changing your circuit:
1. you need to wire the ultrasonic sensor  following the diagram in Ultrasonic Sensor Part 2.|
2. you need to remove the button and replace it with a wire.  Click here to see what this looks like. 

Programming requirements:
Your program should include a function that tells the robot what to do while it is searching for an obstacle. If you need a refresher on Arduino Functions follow this link.

Programming – you can work in Tinkercad OR go directly to real components.  While I would start in Tinkercad, the choice is up to you.
1. make a copy of your code from the first version of this robot.
2. click here for starter code.   You will need to add your OWN code for making the robot drive straight, stop and turn.
3. you only need ONE loop function (named void loop() ).  Don’t add a second loop function.  Instead, modify the one that you already have.

Test your robot:
1. setup some boxes as obstacles.
2. let the robot drive towards the obstacles.
3. questions…
>does it stop?
>does it turn?
>does it have enough room to turn?