In this project, we will use several ultrasonic sensors to create a robot car with obstacle detection feature. The sensors will help us estimate the distance of the car from the nearby obstacles. Thus allowing us to create routines that we can execute when the car is about to hit the obstacle while moving. If you want to know more on how an ultrasonic sensor work, please refer to 4Duino Ultrasonic Sensor project documentation.
This project makes a robot car move in a straight line unless it detects an obstacle. If an obstacle have been detected, the robot car will simply try to avoid it by turning left or right. In case, there are obstacle present in the left and right, the robot will instead move back. If it detects an object in all four directions, it will stop.
How it works
- 2 Motors
- Motor Driver
- 4 Ultrasonic Sensors
- µUSB cable
- 5 Volts Power Supply
Step 1: Build
Build the circuit as shown in the following diagram and table.
Step 2: Program
Workshop 4 – 4Duino Basic Graphics environment is used to program this project.
This project requires the Arduino IDE to be installed as Workshop calls the Arduino IDE for compiling the Arduino sketches. The Arduino IDE however is not required to be opened or modified to program the 4Duino.
Open this file using Workshop 4.
Note: Download the code here.
Step 3: Comms Port
Connect the 4Duino to the PC using µUSB cable.
Then navigate to the Comms tab and select the Comms port to which the 4Duino connected.
Step 4: Compile and Upload
Go back to “Home” tab. This time, click on the “Comp’nLoad” button.
After uploading, 4Duino will start moving as soon as it detects a display touch.
Step 5: Connect Power Supply
Finally, connect a 5 Volts power supply via µUSB.
Now, here are the states the robot car will do.
The chassis for the robot car was made from acrylic using laser cutting technology. However, you can easily make your own with other materials or buy from the market.