A lot of people want to start building robots but they don’t know where to start. It may seem too sophisticated for beginners when in reality it is not. Hopefully, there is an endless source of knowledge called the internet, where you can find literally every information you want.
This is a good project that can help you build and program an obstacle avoiding car using the Arduino board.
Arduino car project
Here is what we want the car to do: navigate and avoid obstacles.
We could decide to add an option to control this car remotely using Bluetooth, but we will stick with the autonomous behavior for the sake of letting you grasp how simple working with Arduino is.
Our robot will sense obstacles with an ultrasonic sensor mounted on its front, the brain of it will be an Arduino UNO clone, we will use a cheap chassis that you can easily buy online with very popular cheap motors. To control the motors we will need 2 channel motor controllers also called H bridge (it is made out of transistors whose connections look like the letter H and that’s why it is named H bridge, this way of connection between transistors allows you to change the direction of rotation of a motor).
We will also need some cables to connect everything together. And just to let you know, soldering is not needed in this tutorial.
Here is a list of parts needed for this project:
- Arduino UNO (you can also use others but connections may change)
- Chassis with 2 motors
- Motor controller L298
- Ultrasonic sensor
- Jumper wires
That’s all you need and it shouldn’t cost more than $30. You can also find a lot of kits having all these components.
Let’s start by fixing all the components to the chassis. You can use M3 screws.
While assembling, make sure that you will be able to connect the cables to those components. Sometimes it is impossible to fix for example an Arduino with 4 screws so you can use 3 or at least 2 to make it rigidly tied to the chassis.
To fix the ultrasonic sensor, I used a 3D printed part that I designed in AutoDesk Fusion 360, you can download it here. If you do not have a 3D printer, don’t worry, you can find a cheap sensor holder on Amazon or simply mount it on the chassis the best way you can.
On the image above, you can see how I placed the mounting screw to receive the Arduino board. On the next image, the Arduino board is fixed to the chassis.
There were only 2 holes to mount the motor driver so I used them.
Here are all the connections we have to make. Different colors represent different signals and voltages. Before plugging in the battery, make sure that everything is connected correctly, otherwise, you can burn something.
If a motor is rotating in the opposite direction than it should, you have to change its polarity (just swap the black cable with the red one).
And now it’s time to upload the code into the Arduino board. Copy the code above, Open you Arduino IDE, paste the code and upload it to the board.
The code is a very simple one. It just lets the robot go forward as long as there is no obstacles in front of it when it senses an obstacle, it randomly rotates left or right and goes forward again until the next obstacle has been found.
You don’t need to add any extra library to get this working, the code is all you need. It is so simple I think you will have no problem understanding it. It is kind of perfect for beginners. As an exercise, you can try writing your own program similar to this one, this way you will better understand how things work and hopefully be able to create a more advanced program based on this project. You can also play with variables at the beginning of the programs. They determine the rotation time, frequency of sensor reads and so on.
Now we can test our robot. Put it on the floor and plug it to power. Your robot should start moving 3 seconds after connecting the battery.
You might also like:
- Arduino hx711 tutorial
- Arduino magnetic switch
- Best Arduino Kits
- gifts for engineering students
- gifts for engineers
- mpu6050 Arduino projects
- Current sensor Arduino
- Soil Moisture Sensor With Arduino
- Arduino Count up Timer Using the Nokia 5110 LCD
- Arduino Yun: Integrating or Juxtaposing Arduino with Linux
- Arduino Projects: Line Follower Robot
- Arduino RFID Project for Beginners
- Arduino MOSFET Project
- Which Arduino Should You Buy
- What Can You Do With Arduino Boards?
- Great Alternatives to the Arduino Microcontroller
- Arduino Projects: Color Sensor
- Arduino IDE Alternatives
- Arduino Mega vs. Uno
- Arduino Projects: Arduino LCD Display
- Read Arduino Rotary Encoders
- A Selection of the Best Arduino Simulators
- Arduino Projects: IR Receiver
- Arduino Light Sensor Project
- Arduino Projects: Arduino Decibel Meter
- Arduino Stopwatch Project
- Arduino Bluetooth RC Car Project
- Arduino Temperature Logger Project
- Arduino Projects: Arduino 7 Segment Display
- Arduino Projects: Clap ON Clap OFF Light
- Arduino Relay Project
- How to install Arduino Library
- Rain Sensor Arduino Project With Buzzer
- Arduino Projects: RGB LED Arduino
- Arduino Stepper Motor Project
- Arduino Projects: Arduino DC Motor Control
- Best Arduino robot kit
- Arduino 3D Printed Case
- Arduino Projects: Asynchronous LEDs Blink
- Arduino Projects: Ultrasonic Distance Sensor
- Arduino Projects: LED – 4X4X4 LED Cube
- Arduino Car Projects: Build an Obstacle Avoiding Robot With Less Than $30
- Arduino Projects: Servo Potentiometer Control
- Arduino LED Project: Knight Rider
- Arduino Projects: PIR Motion Sensor
- Raspberry Pi vs Arduino
- Top 9 Books Every Engineer Should Read
- Arduino Sensor List
- First Hand on the Arduino Uno Board