A rite of passage for most Arduino experimenters is putting together a small robot car. It’s a great project that will teach you a lot of useful skills while also impressing your friends.
A number of robot car bases are available for just such a project. These inexpensive bases are generally made of acrylic and come complete with a set of small DC motors. If you’ve been following the DroneBot Workshop website or YouTube channel then you’ve seen me use a few of these before. They are an excellent way for a seasoned experimenter to put together a small robot car without needing to worry about the mechanical parts.
But for a beginner a robot car can still seem to be a daunting project to undertake. While the robot base can make it a bit simpler you still need to contend with mounting the parts (which may involve some drilling), wiring everything up (and that could require soldering) and finally programming your creation to do something amazing.
There is another solution – build a kit. This has the advantage of having all of the components in one place and, assuming the kit is of reasonable quality, being reasonably assured that your efforts will be rewarded with a working robot car.
In this article, and in the ones that follow it. I’m going to take you through the construction and programming of a high-quality robot car kit. It’s from Elegoo and it’s called the “Elegoo Smart Robot Car Version 3.0”.
The Elegoo Smart Robot Car boasts a pretty impressive set of features:
Combine that with an excellent set of instructions and some prewritten Arduino code and you have a kit that is perfect for Arduino experimenters of all ages and skill levels.
The Elegoo Smart Robot Car kit is packaged in a sturdy reusable orange carrying case, Internally the case has two sections and several compartments used to hold the robot car components. A diagram on the inside lid of the case has an illustration of all the components included in the kit.
The contents of the kit are as follows:
One very nice thing about this kit is that the hardware required to assemble everything is packaged in several individual labeled plastic bags. This makes assembly very simple.
So now that you’ve seen the contents of the Elegoo Smart Robot Car kit it’s time to put it all together!
Assembly of the Elegoo Smart Robot Car is made easy thanks to the excellent instruction manuals provided in PDF form. These manuals (and several code samples) are available on the included CD ROM and can also be downloaded from the Elegoo website.
I downloaded the manuals and code to ensure that I had the latest version.
The kit includes a couple of small Phillips screwdrivers and a 2.5 mm hex key, which are really all the tools you’ll need to build the kit. I added a couple of pairs of pliers to make things a bit easier but they are not completely necessary.
Elegoo has simplified the assembly by packaging the mounting hardware into individual plastic bags, each one labeled clearly with the section that it is intended to be used for.
The first step is to install the aluminum mounting blocks onto the four DC motors. These are mounted using a couple of long screws that pass through the motors. Make sure to install the blocks on the side of the motors that the connecting cable protrudes from. The blocks themselves can be installed in either direction as the threaded mounting holes used to secure the motors to the chassis are on both sides of the blocks.
After the blocks are mounted on the motors you can attach the motors to the bottom base plate.
Before you work with the base plate you will need to peel off the protective coating from both sides. Make note of the side labeled with an “A”, this is the top side.
The four motors are fastened to the base plate using the blocks you just installed. Pass some screws through the base plate into the threaded holes in the aluminum blocks and tighten them. You’ll want to make sure that the motors are aligned flush with the edge of the base plate before you fasten them permanently.
Keep the base plate handy as it’s used in the next step.
The L298N is an H-Bridge driver capable of driving two DC motors. The board used in this kit has been modified to have two connectors for each motor output as the motors on each side of the robot car are wired in parallel. The board also has connectors on it for the data and power cables it will need to function.
The board is oriented with the heatsink facing the back of the chassis.
The board mounts onto the bottom base plate using four M3x14 screws and four small spacers. Pass the screws through the mounting holes on the L298N first, followed by the spacers and then pass these through the holes in the base plate. Finally, use four M3 nuts to secure the screws.
After you have mounted the L298N you can connect the four motors to their respective connectors. The connectors are keyed so they can’t be installed backwards.
The next component to install on the bottom base plate is the line follow sensor array. This mounts underneath the chassis using four threaded spacers, four M3x7 screws and four M3 nuts.
When mounting the line follow sensor array make sure to orient it so that the sensitivity trimpot is facing the front of the robot car. This will position the connector on the sensor array near the large hole in the chassis which is used to pass a cable through.
It is now time to move on to the top chassis plate. As with the bottom plate it is supplied with a protective covering which must be removed.
Make note of the label on the covering first, it indicates the side that is facing up. Unlike the bottom plate it is imperative that you get this right or you’ll need to unmount the components and start again, which I’m sure is not what you want to do!
The first component that we will mount on the top chassis plate is the Arduino Uno. You will use three M3x14 screws and three spacers to mount the Arduino as one of the mounting holes on the Uno is not used. The screws are held in place with three M3 nuts.
After mounting the Arduino Uno board you will install the custom interface shield onto it. As with any Arduino shield you need to be careful to line up the connection pins.
The battery compartment is the next component to add to our Smart Robot Car. You’ll be using four M3x10 screws to mount the holder. Note that these screws have a Phillips head so you’ll need to use an appropriate screwdriver on them, a couple of small Phillips screwdrivers are included in the kit.
You’ll need to take the top off of the battery compartment to get access to the holes for the screws. And of course it needs to be off so that you can install the batteries!
Align the holder so that it is flush with the edges of the top plate and then insert the screws. These are held in place with four M3 nuts.
After you get the holder mounted and secured install the two 18650 LiPo batteries (these come from the factory already charged, although you may want to top them up with the supplied battery charger). Make sure that you orient the batteries correctly, the battery compartment has an illustration inside it showing the correct direction to install the batteries.
Once you get the batteries into the holder you can close the cover.
The final step with the battery holder is to connect it to the power connection on the shield. Before you do this make certain that the power switch is in the “off” position, as we don’t want to apply power to the shield and Arduino right now.
The Servo Motor is mounted next. This motor will hold the Ultrasonic sensor assembly.
The servo is mounted onto a separate base plate that you will find in the same package as the holder for the Ultrasonic sensor. Attach the servo motor to the plate using two small M2x10 screws and secure it with two M2 nuts. Note that the screws are passed from the bottom of the plate. See the manual for the correct orientation of the motor.
Once the motor is installed on the plate you can mount it to the top chassis plate using three M3x10 screws and M3 nuts.
When you have the servo in place you can pass the servo cable through the hole in the top plate and attach it to the connector on the shield. Make sure you connect it in the right direction, the shield is labeled with the Ground connection which is the brown wire on the SG90 servo.
The next step is to install the Ultrasonic sensor onto its mounting bracket. This is accomplished using four very tiny M1.6×8 screws, note that these screws are Phillips head and require the very tiny screwdriver supplied with the kit.
Once the Ultrasonic sensor is secured to its mounting plate you can place the assembly onto the shaft of the servo motor. You will want to align the assembly so that the sensor is facing forward, it might not be exactly flush with the front of the car as it needs to mesh with the gear on the shaft.
After you have the sensor mounted you can use the cable provided to connect it to the shield. It’s the only 4-conductor cable in the kit so it’s pretty easy to distinguish it, and as with all of the cables it is keyed so that it will only fit one way.
The small screw to hold the bracket to the motor shaft is packaged with the SG90 servo. The package also includes a number of screws and arms that are not used in this kit, keep them for future projects.
Our robot care is beginning to take shape! Now it’s time to wire it up.
Before you start connecting everything up you will want to install the six copper spacers that hold the bottom plate to the top plate. I mounted them onto the bottom plate using six M3x10 screws, six more screws will be used to mount the top plate later.
The cables that come with the kit are all unique so you shouldn’t have any problem figuring out which one is which, but if you do just take a look at the illustrations in the manual for guidance.
Begin with the Line Follower sensor. Connect one end of its interface cable to the sensor board and then pass it through the hole in the base plate. Don’t connect the other end just yet.
Now move on to the L298N motor driver. It requires two cables, a power cable and an interface cable. Again these are unique cables so you’ll be able to determine which ones to use pretty easily. Once again you’ll leave the other ends unconnected for now.
Now take all of the cables you’ve just connected to the base plate components and pass them up through the hole on the top base.
You may now use the six M3x10 screws to fasten the top plate to the six copper spacers.
Finally, hook the cables to their respective connectors on the shield.
The installation of the Bluetooth module is very simple. The module has a connector that plugs into a mating socket on the shield. Simply snap it onto this connector and you’re done!
One thing to note is that when it comes time to program the Arduino board you’ll need to remove the Bluetooth module as it shares the same serial data line as the Arduino USB connector.
The final step in assembling the Elegoo Smart Robot Car is to install the four tires onto the motor shafts. The shafts are keyed to mate with the mounting holes in the tires.
Press the tires onto the motor shafts and then secure them with the long M2x25 screws. These are Phillips screws so you’ll need to use the correct screwdriver.
The robot car is now assembled!
The robot car has a lot of features but today we will simply make sure it is working. In part two and three of this series I’ll show you how to use the Bluetooth, IR Remote, Line Following and Collision Avoidance features.
Elegoo has provided some sample code on the CD-ROM included with the car, you may also download the latest version of the code from their website. The sample code is divided into “lessons” and lesson number one is “make the car go”. Looks like a great place to start!
Lesson one consists of the following code samples:
Each sketch essentially shows you how to drive the L298N motor controller to move the car. If you are not familiar with the L298N H-Bridge motor controller please see the article and video covering this device.
We will examine the AUTO_GO sketch and then use it to control our Elegoo Smart Robot Car.
AUTO_GO.ino //www.elegoo.com // The direction of the car's movement // ENA ENB IN1 IN2 IN3 IN4 Description // HIGH HIGH HIGH LOW LOW HIGH Car is runing forward // HIGH HIGH LOW HIGH HIGH LOW Car is runing back // HIGH HIGH LOW HIGH LOW HIGH Car is turning left // HIGH HIGH HIGH LOW HIGH LOW Car is turning right // HIGH HIGH LOW LOW LOW LOW Car is stoped // HIGH HIGH HIGH HIGH HIGH HIGH Car is stoped // LOW LOW N/A N/A N/A N/A Car is stoped //define L298n module IO Pin #define ENA 5 #define ENB 6 #define IN1 7 #define IN2 8 #define IN3 9 #define IN4 11 void forward ( ) < digitalWrite ( ENA , HIGH ) ; //enable L298n A channel digitalWrite ( ENB , HIGH ) ; //enable L298n B channel digitalWrite ( IN1 , HIGH ) ; //set IN1 hight level digitalWrite ( IN2 , LOW ) ; //set IN2 low level digitalWrite ( IN3 , LOW ) ; //set IN3 low level digitalWrite ( IN4 , HIGH ) ; //set IN4 hight level Serial . println ( "Forward" ) ; //send message to serial monitor digitalWrite ( ENA , HIGH ) ; digitalWrite ( ENB , HIGH ) ; digitalWrite ( IN1 , LOW ) ; digitalWrite ( IN2 , HIGH ) ; digitalWrite ( IN3 , HIGH ) ; digitalWrite ( IN4 , LOW ) ; Serial . println ( "Back" ) ; digitalWrite ( ENA , HIGH ) ; digitalWrite ( ENB , HIGH ) ; digitalWrite ( IN1 , LOW ) ; digitalWrite ( IN2 , HIGH ) ; digitalWrite ( IN3 , LOW ) ; digitalWrite ( IN4 , HIGH ) ; Serial . println ( "Left" ) ; void right ( ) < digitalWrite ( ENA , HIGH ) ; digitalWrite ( ENB , HIGH ) ; digitalWrite ( IN1 , HIGH ) ; digitalWrite ( IN2 , LOW ) ; digitalWrite ( IN3 , HIGH ) ; digitalWrite ( IN4 , LOW ) ; Serial . println ( "Right" ) ; //before execute loop() function, //setup() function will execute first and only execute once void setup ( ) < Serial . begin ( 9600 ) ; //open serial and set the baudrate pinMode ( IN1 , OUTPUT ) ; //before useing io pin, pin mode must be set first pinMode ( IN2 , OUTPUT ) ; pinMode ( IN3 , OUTPUT ) ; pinMode ( IN4 , OUTPUT ) ; pinMode ( ENA , OUTPUT ) ; pinMode ( ENB , OUTPUT ) ; //Repeat execution forward ( ) ; //go forward delay ( 1000 ) ; //delay 1000 ms back ( ) ; //go back delay ( 1000 ) ; left ( ) ; //turning left delay ( 1000 ) ; right ( ) ; //turning right delay ( 1000 ) ;In order to understand the operation of this sketch (and all of the other ones mentioned here) you will need to know how the L298N is connected to the Arduino on the car. The connections are as follows:
Note that the two Enable lines are connected to Arduino pins that are capable of PWM (Pulse Width Modulation). This allows us to control the speed of the motors. The motors on each side of the car are connected in parallel.
The AUTO_GO sketch starts by defining the Arduino pins used to control the L298N. These are all set as outputs in the Setup routine.
There are four functions defined, one for every direction that the car can travel. Each function also prints to the serial monitor, which is optional.
Finally in the loop we just call each of the direction functions, followed by a one-second pause.
The result is that the car moves forward for a second and then reverses for a second. It then turns left for a second and then right for a second. After that the loop repeats itself.
One important note – before you connect the robot car to your computer you’ll need to remove the Bluetooth module. This is true every time you program the car as the Bluetooth module uses the same transmit and receive lines that the USB connector uses and the two will conflict with each other.
The Elegoo Smart Robot Car is a well designed and high-quality kit. The parts all fit together perfectly and the instruction manuals are excellent. I think anyone would find this very easy to assemble.
This kit would be perfect for educating students of all ages who are new to the Arduino and it’s a very good value – in fact it would be very hard to get all of these components together for a lower price. I highly recommend it.
In fact, if you are reading this article before December 6th 2018 you can get the Elegoo Smart Robot Car Kit from Amazon at a discount price. It is normally priced at a very reasonable $69.99 but it is currently priced at 59.99 and there is a 7 dollar coupon you can apply making the grand total $52.99.
This concludes the first part of the series on building and using the Elegoo Smart Robot Car kit. In the next installment I will show you how to use the Bluetooth and Infrared remote controls and then we will cover the line follower and collision avoidance in the final article and video.
Until then enjoy your kit and happy driving!
Here are some components that you might need to complete the experiments in this article. Please note that some of these links may be affiliate links, and the DroneBot Workshop may receive a commission on your purchases. This does not increase the cost to you and is a method of supporting this ad-free website.
Elegoo Smart Robot Car – The sales page for the Elegoo Smart Robot Car
Elegoo Robot Car Software – The latest version of the instruction manual and the software for using the robot car.