Last year we attempted to make a tank with arduino. Theoretically, she would have been controlled with an infra-red remote and also have been the coolest little car on the block. Her name was Bessie, and she failed miserably. She was barely controllable and her gears would become misaligned on a regular schedule. We vowed not only to never touch an IR receiver again, but also to do better next time. Thus, Bessie's son was born.
His name is Eisseb (see what we did there). Eisseb is our obstacle avoiding car. He began as a fancy RC car chassis, and with some modifications, plus an arduino uno and a sonic sensor, he became what he is today: awesome.
BUT WAIT! There's more: We did the work, so you don't have to!
Okay, that's a lie, but we did write down what we did. Hopefully, the world will soon be full of sonic sensor cars for Eisseb's robot army.
- MATERIALS -
1. Arduino Uno (duh)
2. Jumper wires (We used a total of 27)
3. L298N Motor Shield
4. 4S 2P Battery Pack + Batteries
5. Bread Board
6. 24 volt DC Motor
7. Switch
8. 2 Servos
9. HC- SR04+ (Sonic Sensor)
10. Cardboard for sensor platform
12. RC car chassis
- YOU'LL NEED THESE TOO -
1. Tape (Electrical and Duct)
2. Hot Glue
3. Screw Drivers (Depends on chassis)
4. Wrenches (Depends on chassis)
5. Wire Cutters
6. Soldering Iron + Solder
7. Zip Ties
- OPTIONAL -
1. Turtle Shell and Brackets
(Files Below)
Although we'll tell you where your wire connections will be in each individual step, it may also be helpful to look at a full system schematic so that you can get an idea of how to arrange parts onto your chassis.
As for the chassis itself, you have a lot of options. Ours was a from an Duratrax Evader EXT car, but you could really use anything that works for your purposes. Using a remote control car chassis is helpful, because often times the steering servo is already build into the car. If you really wanted to you could probably just use a piece of wood with some wheels slapped on it. Whatever you're using, make sure there is enough space for all of the systems to fit and be securely attached.
When we first started off on this project, we originally had only a 8 volt battery pack. We soon found this to be insufficient for our 24 volt motor, so a redesign was once again in order. We decided to take another set of our 18650 rechargeable batteries and another battery pack, and combine them with some tape on the back to secure them together. You then need to take one red wire from a battery pack and a black from the other and solder them to the bottom of your L289N under pins GND and 120 (Black=GND Red=120). The remaining black and red wires are then attached to a switch.
We attached the wires to a switch in order to have an easier and smoother transition between turning Eisseb on and off. This is completely optional but we recommend it so you can save your batteries’ juice and not have to waste as many batteries if you’re not using rechargeable ones.
As stated previously, Eisseb the car has a 24 volt dc motor attached to a L298N motor shield. Depending on what kind of chassis you are using, you may need to create a gear system similar to the one shown above connecting to the axle of the car. If you are using an RC car chassis, it will most likely already have a gear system and maybe even the type of motor you need.
*Note: This could be modified to work with many types of motors. Our first draft of the car had a brushless DC and and an electronic speed control device. This obviously did not go as planned, or else we would have a totally different instructable*
Once your motor is attached to your chassis and is appropriately connected to the axle, it's time to add the motor shield. You'll have to solder jumper wires onto the two inputs of the DC motor. Those two wires are attached to OUT1 and OUT2 on the shield ( They are labeled, it's tiny and on the bottom). They can be screwed in or soldered on.
Now to connect the motor shield and power source to the arduino:
First, connect the shield. Remove the cap from the ENA (enable A) pin. These pins are labeled in tiny print too, but at least they're labeled on the top of the shield. Take a jumper wire from the ENA pin on the shield to pin 10 on the arduino. Take another wire from IN1 on the shield to pin 9 on the arduino, and a third wire from IN2 on the sheild to pin 8 on the arduino. You won't need the other EN or IN pins unless you are driving 2 motors.
Next, connect the power source. The arduino uno can run off of power from the USB cable, but also on 5 volts being input from other places. But, before you start hooking the power to the arduino, it's a good idea to have a breadboard power strip set up. All you have to do is take a wire from the arduino uno's GRD to one end of the '--'strip on the breadboard, and another wire from the arduino's 5V to the same end of the '+' strip on the board. Now you have a place to consolidate all of you positive and negative wires.
To create the power circuit from the motor shield to the arduino, screw a jumper wire into the GRD port on the motor shield, and plug the other end into the negative side of your breadboard power strip. Then, screw another jumper wire into the +5V port on the shield, and connect the other end to the arduino's VIN pin.
Now, with the right code, your car should be able to go forward and back. The next step will help you make it turn.
The servo steering for our car was pre-done when we got the chassis, all we had to do was take up the three wires (Ground, power, and control) that the servo was attached to from the previous car and hook them to a breadboard. You can also see this example on the schematic on step 2.
*Control pin goes to 7 on the arduino*
If you do not have a chassis that comes with a pre-made steering system then that’s okay too! All you need to do is take a servo and attach it to an axle and connect two wheels on either side. This will give you a similar take on the pre-made one that we had.
Now that you have a fully functioning autonomous car, it's time to start on the obstacle avoidance. The sensor works best if it is on a servo mounted on the front of the car because it then has a wider range of vision. I'll be perfectly honest though: small chair legs are somehow mysteriously invisible to this sensor regardless of the circumstances. I don't know why, but they are.
This system is probably the least complicated of them all. The servo's positive and negative plug into your bread board power strip, and it's control plugs into arduino pin 4.
You may want to mount the servo facing slightly downward to avoid glitches the sensor tends to have when it senses extremely long distances. Pointing down limits it's range to the direct vicinity of the car. Also make sure the servo is positioned so that the sensor will sweep 180 degrees in front of the car when it moves. There's no sense in your car sensing itself. Finally, hot glue is essential for this step.
For the next part of your cool robot, you’re going to need to make it autonomous. To do this you will need to get another servo and mount it somewhere on the front of your car. (We conveniently had a nice little spot for ours but you may need to make one out of wood, plastic, or cardboard.) Wire the servo back to your breadboard and then attach a sonic sensor to the top of your servo (we used cardboard).
*Trig = pin 13 Echo = pin 12 Ground to Ground strip on bread board, power to power strip*
You may want to cut out a small hole to run the wires from the sensor to the ardiuno, this makes it more efficient and easier to deal with. Make sure that whatever material you are using to mount sensor is able to be cut or molded to fit your needs.
*Refer back to step 2*
This step is not necessary but it totally looks cool. I made a turtle shell for our autonomous robot to keep all of the wires and stuff safe inside while also looking pretty awesome as it drove down the hallways of our school. It's a simple design that I made in Tinkercad. Tinkercad is a web browser based simplified 3D modeler.
In Tinkercad all I did was make an oval and some cones to make the spikes, I then measured it out to fit our car and printed it out on our 3D printer. The files are available for you to use, the program is super simple and you are more than able to take the design and make it your own.
*We needed to also print out brackets to attach the shell to the sides of the car via zip ties.*
This code is meant to be changed. It has several different functions for controlling the car, and the sensor function is completely separate so you can mix and match as you please. Currently, a simple go-forward-and-sense function is in the void loop. We have provided this function (called pattern) as well as a function that drives the car in loops while sensing (called pattern1) for you to use in your car.
I would recommend that you use the 'pattern' function to test your car's systems when it is complete, because it is the simplest code to run all the car's systems. All of the code is annotated so that you can easily change things if you wish. If you have used different materials (different motors or shield ect.), you may need to change parts of the code.
Everything is done! Your car has a controllable motor, steering, a rotating sensor, and maybe even an awesome shell!
We would reccomend that at this point you batten down the hatches. Zip tie your wires together, glue down boards and shields and attach any shell or cover you have for the chassis to protect the hardware. The more durable the better, because if your car happens to bump into something or someone, you want it to bounce back!
So- there are definitely some upgrades you could make to this car. If you can, we would reccomend-
- add more sensors, maybe on the back so in tight squeeze, it's easier for your car to navigate
- do more cool 3rd printed add ons!
- make it 4-wheel drive
- modify the sensors to be more accurate
- make it faster
- or slower, so it never hits things
Anyway, have fun with it!
Your car will be an awesome addition to Eisseb's car army.