Smart Robot Car
Smart Robot Car
by rricklic
Materials:
Arduino UNO R3
L293D motor drive shield
HC-SR04 ultrasonic sensor
holder for HC-SR04
TowerPro SG90 servo motor
SG90 servo arms
mount for HC-SR04 and SG90 servo
2 gear motors (1:48) 3V-6V DC
2 tire wheels (65mm)
wheel mounts
2 speed encoders
caster wheel
4 AA battery pack
rocker switch
car chassis
screws
nuts
extender nuts
wires
male headers
4 AA batteries
9v battery (optional)
9v battery power cord (optional)
Tools:
soldering iron
solder
solder wick
Phillips-head screwdriver
needle nose pliers
wire stripper
breadboard or foam pad (optional)
multimeter (optional)
Software:
Arduino IDE
computer
USB cable A-male to B-male
1 6
2 4
13
3
12 4
19 11 3 5
15 22 14
2
20
6 7 10 9 21
8
7
16 17 23 24
18
1. Arduino IDE
2. USB cable A-male to B-male
3. computer
Carefully slide the ultrasonic sensor holder around the transmitter and receiver protrusions.
You may need to file the holder holes or bend the transmitter and receiver to get it to fit.
Alternatively, you could sandwich the wires between the shield and Arduino if soldering is not your thing.
Secure the servo mount to the chassis with 2 screws and 2 nuts.
Try to center the servo as much as possible.
Attach a servo arm to the servo holder with 2 screws.
Be careful not to use screws that are longer than the base of the arm as it will prevent it from attaching to the servo
motor securely.
Attach the shield onto the top of the Arduino making sure that the male pins line up with the appropriate female
pins.
Secure the Arduino and shield to the chassis with 2 screws and 2 nuts.
Depending on the length of the screws, additional nuts may be necessary to act as spacers to ensure the Arduino
it securely attached to chassis.
There are dedicated servo pins on the motor drive attach 4 wire jumpers.
shield so attach the servo cord to "servo one" being Attach the opposite ends to the power, ground, A5,
sure the colors are brown, red, and orange for pins 1, and pin 2 headers soldered in from earlier.
2, and 3 respectively. The remaining pins can be used for future projects.
Bend the pins on the ultrasonic sensor so that they
are perpendicular to the back of the sensor and
1. Brown-red-orange
1. Ground-2-A5-Vcc
1 2 1
1. Vcc-ground 1. 2 (Echo)
2. A5 (Trig)
Remove any connections from the wires soldered to the motors and attach to the motor drive shield.
In this case, motor 3 and 4 on the shield were used due to their close proximity to the motor terminals.
Depending on how you soldered the wires to the motors, you may need to switch the wires at the screw terminals
Secure the battery pack to the chassis with 2 screws and 2 nuts.
Snap the rocker switch into place with the terminals facing upwards.
Cut the power (red) wire roughly in half so that we Optionally, a 9v batter can be used to power the
can solder it through the rocker switch. Arduino separately.
Attach the power wire from the switch and the ground Powering the Arduino separately will prevent any
from the battery pack to the power and ground voltage drops from resetting the Arduino code being
terminal on the motor drive shield. executed.
This will also power the Arduino. Similarly, the 9v battery could also be wired into the
Put 4AA batteries into the battery pack, hit the switch switch instead of the battery pack.
to the "on" position, and ensure that both the motor
shield and Arduino power indicator lights are
illuminated.
Download the Arduino IDE for your operating get proper clearance.
system and architecture: Open up the program sketch in the IDE.
https://www.arduino.cc/en/Main/Software Download Under the "Tools" menu item, ensure that the board is
the program sketch: set to "Arduino/Genuino Uno" and that the port is your
https://github.com/rricklic/arduino.uctronics.robo... Arduino (eg: /dev/ttyACM0).
The code will have the car move forward at full speed Hit the check button to ensure the sketch compiles.
until it detects an obstacle. Hit the arrow button to upload the sketch to the
It will scan from 60 to 120 degrees in front and attached Arduino.
determine if it should back up and turn left or right.
Once done it will continue moving forward again at NOTE: If you are using a Linux distribution as your
full speed. operating system, you may need to set permissions
by adding your user to the "dialout" group:
How to upload program sketch to Arduino Uno: $ sudo usermod -a -G dialout $USER
Attach the USB cord to your computer and the other
end to the Arduino. Rebooting makes this change permanent.
You will likely need to remove the ultrasonic sensor to
1. check = compile
arrow = upload
The code was made fairly simple, but the functionality is defined well in functions allowing for easily modifying the
default behavior. There are also 5 analog pins that can be used for more sensors (eg: optical sensor for use with
speed encoders), room for 2 more motors on the shield, and a set of servo pins so this base car can be enhance
quite a bit!