Ever since I started programming with Arduino, I wanted to build a robot using one. I also want a dog. However, living in NYC makes it tough to take care of one so after hours of watching videos of robots, and dogs, I decided to put my phone down and build myself a pet.
I present to you , DoggoBot Version 1. Doggobot is a 4 legged walking bot controlled with an Ardunio Nano. Each leg of the bot is moved via a metal geared micro servo. DoggoBot uses a 7.4 LiPo battery and a 9 volt battery which power the legs and the Arduino, respectively. DoggoBot can communicate with its owner over a bluetooth connection using a smartphone app.
The electronics are fairly simple and require no soldering. All of the parts can be purchased from Amazon although shopping around may save you a few dollars. The structure of the bot uses a few 3D printed parts but is mostly cardboard held together with hot glue. I used a laser cutter to cut the cardboard but if you have a a knife and a steady hand, you could cut all of them from whatever scrap corrugated cardboard you have waiting to be recycled.
DoggoBot's brain is an Arduino Nano. The code was written with the Arduino IDE. The smartphone app was built with MIT's App Inventor. Both pieces of software are free to use. The app was built for Android based phones but the app is simple enough a clever app builder should have no problem recreating it for use with iPhones.
In this version, the code lets DoggoBot walk forward and stand. The app allows command of these functions through button presses or voice commands. The code was written in a way to be used as a platform to add more functionality with minimal effort.
Through this instructable, I'll go over what you need and how to make DoggoBot. I'll also share the code so you can experiment with your own version.
Step 1: Gather All Your Parts
As mentioned before, all of these parts can be bought from Amazon. However, I'd shop around. Websites like Adafruit, Sparkfun, Mouser, Digikey, RobotShop and others may have better deals. I've posted links next to the items from sites who had a good description of the part. Also, I made some notes for each part. Some can be swapped and others do not need to be the exact value. I
4 x Tower Pro MG90S Metal Geared Micro Servo Adafruit
You could go for the plastic geared motors, which are cheaper.
However, they are not as durable and have not been tested with this project.
1 x Arduino NanoArduino
You could use any Arduino. The Nano just fits nicely onto a breadboard
2 x 100uF Electrolytic Capacitor Adafruit
These are needed to smooth out the power supply for the servo motors and prevent back EMF going to the battery. I've seen diodes used instead but have never tried them.
1 x 5 Volt Regulator SparkFun
This brings the voltage from the battery to 5 volts for the servos. Your servos will last a lot longer and perform much better with a regulated power supply.
1 x HC-05 or HC-06 Bluetooth Module NewEgg
The HC-06 can only recieve input while the HC-05 is a transceiver, which means it can recieve and transmit data. Its important to know which type you are using for both troublshooting errors and knowing what to connect to when you setup the app. Use the HC-05 if you want your DoggoBot to "talk" back to you. Use the HC-06 if you want your DoggoBot to only "listen" to you.
1 x Half Size Breadboard Adafruit
A half size breadboard fits all of the components fine but a larger one would work just as well.
1 x 7.4 1200 mah LiPo Battery NewEgg
The servos will need 5 volts and a few hundred milliamps each. This LiPo battery can give plenty of milliamps and we can regulate the 7.4 volts down to 5 volts easily. The added bonus is the battery is rechargable. Take caution when recharging LiPo batteries. The battery and charger in this list match and work well together.
1 x LiPo Battery Charger NewEgg
Good charger for the battery above. Again, take caution when recharging LiPo batteries. Do not leave them charge overnight.
1 x 9 Volt BatteryAmazon
I ran into some issues when trying to power the Arduino and the servos using just the LiPo battery. The easiest solution is to power the Arduino separately with a 9 volt battery. The 9 volt supplies plenty of milliamps for the Arduino to control the servos and power the bluetooth module.
1 x SPDT Switch Adafruit
This lets you turn off the battery pack which will cut power to the legs. Not having the legs move can be helpful when debugging code.
DC Barrel Jack Adapter Sparkfun
This is used to connect the Arduino to the 9 volt battery. I found this one to be very useful since you do not need to solder anything. You can use a pair of jumper wires as the positive and negative, then place the ends into the breadboard rows with the Arduino's Vcc and GND pins.
9 Volt Batter Barrel Jack AdapterSparkfun
This is used to connect the 9 volt battery to the Arduino.
Male to Male Jumper Wires SparkFun
Much like M&Ms the color is not too important here. The inside is still the same material. However, I find it very helpful to color code things like power, ground and signal lines. The instructions use specific colors for things but feel free to use whatever color you like. This is the amount of each color I used are listed.
1 x Blue
1 x Orange
4 x Yellow
9 x Black
9 x Red
Paper Fasteners Staples
If you do not have access to a 3D printer, you could always use paper fasteners. Any place which sells stationary should have some. A small to medium size works great.
Masking Tape Staples
If you do not have a hot glue gun, you could always use tape to hold the pieces together. Masking tape is easy to work with although stickiness can vary with brands. The cheap stuff often doesn't hold things together too well. Spend a few extra cents and you'll thank me later.
Laser Cut File
If you do not have a laser cutter, you could use this file as a guide to cut the parts by hand. I used a laser cutter to make the tabs and slots of the parts which would be tricky to do by hand. The tabs and slots make putting together the legs a little easier and ensure each leg is square. You could always just generalize the measurements to rectangles and cut the parts out of some scrap cardboard. The file is in ai and svg formats. See the attached zip file for all the necessary part files and code.
3D Printed Parts
The only part to be printed is a hinge pin for each leg which could be replaced by two papers fasteners. The hinge pin makes putting the upper and lower legs together very easy and makes a smoother joint than the paper fasteners. Although, if you do not have access to a 3D printer, paper fasteners would work fine. The file is in stl format. See the attached zip file for all the necessary part files and code.
Hot Glue Gun
An essential tool in the DIY toolkit. These can be bought from 99 cent stores, craft stores, Home Depot, Amazon, etc.
Glue Gun Sticks
You'll need a bunch. Hard to say an exact amount, but I estimate I used 10 to 15 regular sized ones. You could always buy the longer ones if you want.
Laser Cutter Skill Mill NYC
These are harder to come by. They can be expensive to buy and need ventilation. Use Google to search for makerspaces to find a local one to use or search for an online service to get your parts shipped to you. Skill Mill NYC offers laser cutting services as well as classes.
3D Printer Skill Mill NYC
Same as the laser cutter. Although, the prices for these have come down a bit over the years. I bought one for under 300 dollars, although it did need a lot of troubleshooting to get right. Like laser cutters, there are online services which can ship your parts to you or search for a makerspace near you. Skill Mill NYC also offers 3D printing services and classes in design.
These are just extra tools which may come in handy.
Step 2: Assemble the Legs
Lets put the legs together first. You will need the leg parts, hot glue gun and 3D printed parts.
We are going to assemble the upper legs first. Follow these directions alongside the pictures. Try not to over think these too much. I tried to make this as simple as possible to put together. There really are only two steps where you can go wrong so some attention to detail required. Once you finish the leg A, you just need to repeat these steps for the 3 remaining legs.
1. Plug in your hot glue gun.
2. Grab the two upper leg parts labeled A and two small I beams.
3. Grab the upper leg part with the oval underneath the A and one small I beam.
4. Place a line of glue alongside the indent of the I beam.
5. Place the indent of the I beam onto the underside of the tab of the leg part A.
6. Repeat this for the second I beam.
7. Place a line of glue on each of the indents of the I beams.
8. Place the other upper leg part so its tabs are on top of the indents and the A is facing the backside of the other leg A part.When you glue the parts together, you will be able to see both As when looking at the leg.
9. Grab two lower leg parts and two large I beam parts.
10. Place a line of glue in the indent of one of the large I beam parts.
11. Place the indent of the large I beam part onto the tab of the lower leg part.
12.Repeat steps 10 and 11 for the second large I beam part.
13. Place a line of glue onto the indents of the two large I beam parts.
14. Place the second lower leg part so its tabs are in the indents of the two large I beams.
15. Repeat steps 1 through 15 for the remaining leg parts B, C and D.
Step 3: Assemble the Body
We are going to assemble the body and glue the servo motors in place.
1. Gather the parts for the body and 4 servo motors.
2. Grab the battery case wall part and fold along the score lines.
3. Place the tabs of the battery case wall into the slots of the body base part. If you have some trouble getting the tabs to go into place, gently press the tabs with you thumb and pointer finger to make the tabs into a wedge shape. This will help to fit the battery wall into place.
4. Place a line of glue along the base of the walls to secure the battery wall in place.
5. Grab the side wall with B and C labels and place a line of glue along its indent.
6. Place the indent of this side wall onto the tab of the base part. The B and C of the side wall should line up with the B and C of the base part.
7.Grab the side wall with A and D labels and place a line of glue along its indent.
8. Place the indent of this side wall onto the tab of the base part. The A and D of the side wall should line up with the A and D of the base part.
9. Grab the side wall with B and D labels and place a line of glue along its indent.
10. Place the indent of this side wall onto the tab of the base part. The B and D of the side wall should line up with the B and D of the base part.
11. Grab the side wall with A and C labels and place a line of glue along its indent.
12. Place the indent of this side wall onto the tab of the base part. The A and C of the side wall should line up with the B and D of the base part.
13. Grab one of the servo motors.
14. Thread the wires of the servo through the hole labeled A of the side wall.
15. This part is crucial so follow the pictures for a reference. Align the servo motor so that the side with its wires is facing up.
16. Place a small bead of glue onto the side wall, underneath each of the two tabs of the servo motor.
17. Press the servo motor into the side wall to secure it in place.
18. Repeat steps 14 through 17.
The orientation of the servo motors is important because the code assumes the servo motors are oriented with the wires facing up. If you happen to glue them in the opposite direction, you could adjust the code so this orientation will work.
Step 4: Assemble the Breadboard
Set aside the legs and the body. We are going to assemble the electronics on the breadboard.
Quick tip. If you are having some trouble getting the Nano into the breadboard, take a look at the pins. In the second photo, you can see the pins are at an angle. Often the Nanos come this way. Price you pay for cheap Arduinos.
A simple fix is to place the Nano's pins on a hard surface like a tabletop, then gently press the Nano into the tabletop. This will straighten all the pins at once. Do this for the other side.
Do press gently though! You do not want to break the pins from the board.
For these instructions, I refer to the labels on the breadboard. They are set up like a grid. The columns are labeled A to J and the numbers go from 1 to 30.
1. Gather the Nano, volt regulator, capacitors, HC-05, jumper wires, switch and breadboard.
2. Place the Nano onto the breadboard so the Nano's digital pin 12 is at position G1 on the breadboard.
3. Place the volt regulator so its pins are at positions H20, H21 and H22. This part is important so make note of the orientation of the volt regulator as one pin is input and the other pin is output. WILL NOT WORK IF YOU PLACE THIS IN THE WRONG DIRECTION! If you position the breadboard so the the USB port of the Nano is facing away from you, the labeled side of the volt regulator should be facing to the right. See the pictures for a reference. Sorry for yelling....
4. Place one capacitor so the negative side is in position F21 and the positive side is at F22. Make a small bend in the positive side's lead to help it fit.
5. Place the second capacitor so its negative side is at position I21 and its positive is at I20.
Make a small bend in the positive side's lead to help it fit.
6. Place the SPDT switch so its three pins are at position I30, I29 and I28.
7. Place the blue tooth module so its VCC pin is at position E26, GND is at E27, TXD is at E28 and RXD is at E29.
8. Gather the jumper wires sort them into piles of like colors to make things a bit easier.
RED JUMPERS (Power Lines)
9. Place one end of the first jumper at position H30. Leave the other end of this jumper free.
10. Place one end of the second jumper into position H29 and the other end into position F22.
11. Place one end of the third jumper into position J20 and the other end into the far end of the red line of the breadboard. This is to create a 5 volt power rail for the motors.
12. Place one end of the 4th, 5th, 6th, and 7th jumper wires into the power rail of the bread board so they are grouped together and near positions J12 - J9. This will ensure these jumpers are near the hole cut in the top of the body through which the servo wires will pass. Leave the other ends of these wires free. These will go to the VCC pin of the servo motors.
13. Place the 8th jumper at position B12. It should be in the same row as the 5Volt pin of the Arduino Nano. Place the other end of the jumper into the red rail of the breadboard. This is to create a 5volt power supply for sensors and devices such as our Bluetooth module.
14. Place one end of the 9th jumper at position A26 of the breadboard and the other end into the power rail of the breadboard.
BLACK JUMPERS (Ground Lines)
15. Place one end of the first jumper into position F22 of the breadboard and leave the other end free.
16. Place one end of the second jumper into position J21 and the other end into the blue line of the breadboard, next to the red jumper. This will create a ground rail for the motors.
17. Place one end of the 3rd, 4th, 5th and 6th jumpers into the blue line of the bread board alongside of the red jumpers. Leave the other ends free. These will go to the ground pins of the servo motors.
18. Place one end of the 7th jumper into the far end of the blue rail on the breadboard and the other end into the far end of the opposite blue rail of the breadboard. This will connect the two blue rails of the breadboard.
19. Place one end of the 8th jumper wire into position B14 of the breadboard. This should be in the same row as the GND pin of the Arduino Nano. Place the other end of the jumper into the blue rail of the breadboard. By doing this, you are connecting all the grounds to the ground pin of the Arduino. This is crucial for proper operation of the robot. All grounds must be connected.
20. Place one end of the 9th jumper wire into position A27 and the other end into the blue rail of the breadboard. This is to connect the GND pin of the Bluetooth module to ground rails of the bread board.
21. Place one end of each of the yellow jumper wires into positions I9, I8, I7, and I6 of the breadboard. Leave the other ends free. The free end of each jumper wire will connect to the signal pin of the servo motors. Positions I9, I8, I7 and I6 should be in the same row as the digital pins 4,5,6, and 7 of the Arduino Nano respectively. If they are not, just make sure one end of each yellow jumper is in the same row as digital pins 4, 5, 6 and 7 of the Nano.
22. Place one end of the blue jumper into position I11 and the other end into position A28. This is to connect digital pin 2 of the Nano to the TXD pin of the Bluetooth module.
23. Place one end of the orange jumper into position I10 and the other end into position A29. This is to connect digital pin 3 of the Nano to the RXD pin of the Bluetooth module.
Double check your connections with the wiring diagram and then move to the next step!
Step 5: Place the Body Parts Together
We are almost finished. Now we are going to connect the servos and batteries to our breadboard.
Gather the wired breadboard, the body with servos attached and the body top part. The body top part is labeled with A,B,C,D and Breadboard.
CONNECT THE MOTOR BATTERY
1. Place the battery pack into the battery holder of the body.
2. There should be two sets of wires coming from the battery. Thread the set of three wires with the white cap through the small hole of the body side wall. This is to connect the battery to a recharging station without having to remove the battery from the robot.
3. Thread the set of two wires with the red cap through the small hole in the body top part.
4. Make sure the switch on the bread board is set to OFF. I realize there is no ON or OFF label for the switch. However, if you wired everything according to the instructions, the OFF position is when the switch to pressed towards the Arduino.
5. Connect the free end of the black jumper wire into the GND pin of the battery.
6. Connect the free end of the red jumper wire into the Vout pin of the battery.
CONNECT THE SERVOS
7. We are going to connect the servos one by one to make sure they are wired correctly. This is one of the crucial steps. However, do not worry. If you wire the servos in the wrong order you can always detach and reattach the jumper wires to get things write.
8. Thread the wires for servo A through the hole of the body top part.
9. Connect the free end of the yellow jumper wire at position I9 into the signal pin of the servo A motor. The signal pin should be the orange wire of the servo. If its a different color, it should be on the opposite side of the ground wire of the servo. In any case, refer to the specs of your servo motor for the proper wiring.
10. Connect the free end of the red jumper nearest position J12 of the bread board into the VCC pin of servo A.
11. Connect the free end of the black jumper wire next to the red jumper you just connected to the GND pin of servo A.
12. Repeat steps 2 through 5 for servos B, C and D. For the yellow jumpers, you want to connect them so digital pins 4 goes to A, 5 goes to B, 6 goes to C and 7 goes to D. This is important since the code assumes this connection arrangement. For the red and black jumpers, the order does not matter just as long as the red jumpers connect to the VCC pins of the servos and the black jumpers connect to the GND pins of the servos.
13. When all the connections are made, place the body top part onto the body so its tabs line up to the body's indents.
14. Press gently down on the body top part to have it snap into place. The tabs of the body will fit into the indents of the body top. This should hold every together. You can always add some glue to secure the top in place but I like to leave it without glue in case I need to replace the battery or a motor.
Step 6: Upload and Test Code
Now we can upload our code. Download the code provided. You will need to install Arduino software. This is a simple process. Please refer to their website for instructions.
1. Connect the Arduino Nano to a free USB port on your computer.
2. Open the code in the Arduino IDE.
3. Select the board from your menu and select the port.
4. Upload the code.
5. Turn the switch to the ON position. The motors should move to 90 degrees.
Take a pause to look through the code. You will see in void setup(), after all the pins are setup, the first action is for the robot to call the stand() function. This moves the legs into position so the bot stands. In the code provided, this moves the legs to 90 degrees. For now, this is fine. This will allow us to attach the legs so each leg is centered at 90 degrees. We need this as a reference point and need a proper one to ensure the legs move correctly.
If you scroll down towards the bottom of the code, you will see the details for the stand() function. Its very simple. Its sets the position of each servo to 90 then writes each servo to 90. You will also notice some lines which are commented out. These are positions which I found to be a bit better for the robot. Use your discrection to find values which work best for your bot.
Once the code is uploaded and everything seems right, attach the breadboard to the body top part by placing a few beads of hot glue on the under side of the bread board then placing the breadboard in the region labeled Breadboard on the body top part.
Step 7: Attach the Legs
Homestretch! Now we will add the servo horns to the legs so we can attach them to our bot.
1. Grab the four legs and four servo horns.
2. Take note of the horns. Its hard to see but one side is longer than the other. If you count the holes, you will find one side has 7 and the other has 6. It does not matter which side you use but you must be consistent. If you glue the horn so that the side with 7 holes is at the top, do this for each leg. Otherwise, your bot will not sit level as one leg will be slightly higher than the other.
3. Starting with leg A, add a line of glue to the inside of the oval.
4. Gently press the horn into the glue so its inside of the oval. Try to align the hole of the horn with the hole centered at the oval.
5. Repeat step 4 for each leg.
6. Now just attach each leg to each servo. A to servo A, B to servo B, C to servo C and D to servo D. It will help to look at the labels on the body top part.
7. Secure the breadboard in place with a few dabs of glue.
8. For testing purposes, I find it very helpful to have something to rest the bot upon. A coffee can works great.
To secure the legs to the servos better, use the horn mounting screws which came with the servos. Get a small phillips head screwdriver and guide the screw through the holes of the legs into the hole of the servo horn. A magnetized screwdriver works best for this. Don't have one? Well grab a magnet and pass the tip of the screwdriver over the magnet like you are sharpening a knife. After about 10-20 passes, the tip will have a strong enough magnetic field to hold the screw in place as you guide it into place.
Step 8: Test the Code
Now its time to test the code. If you unplugged the Arduino when adding the legs, plug it back in and upload the code one more time.
By default, the robot is set up to take in serial input. Open your serial monitor and type 1 then press enter. The DoggoBot should start walking. Entering 2 into the serial window will have the bot sit. 0 will make it stand.
Next we can test the Bluetooth portion. I created an app to control the bot but unfortunately I was unable to upload it to the Google Play Store. You will have to install it manually but do not worry, its an easy process.
1. Plug your Android based phone into the computer.
2. Make sure you have it set up so files can be transferred between the computer and phone.
3. Open the DoggoBot Files folder and navigate to the MIT App Inventor files.
4. There is a file called BlueController.apk.
5. Copy this file onto your phone.
6. On your phone, navigate to where you placed the BlueController.apk file and click to install.
7. You may have to adjust your phone settings to allow installation of apps not from the Google Play Store.
8. Alternatively, you can create an account for MIT App Inventor. I highly recommend this as its a fun tool to play with.
9. Once you have your account set up, import the BlueController.aia file into your app inventor project.
10. Select the option to build the app with a QR code.
11. Use your phones QR code scanner to scan the code provided by the app.
12. It will direct you to a link to download the app.
13. Install. The photos here are screenshots of what the app looks like on your phone.
Here are the values the app's buttons send to the Arduino:
UP = 'u'
DOWN = 'd'
LEFT = 'l'
RIGHT = 'r'
A = 'a'
B = 'b'
C = 'c'
X = 'x'
Y = 'y'
Z = 'z'
START = 's'
SELECT = 't'
The voice command sends just a string.
You may have to adjust some of the settings in the Arduino code. If the bot does not sit well, adjust the pos variables in the sit() function to get it to sit properly. Play with these variables until you find one which works.
Do the same for the walkForward() function. You may have to adjust the values of the start and end positions to get the DoggoBot to walk properly. Play with these! The idea behind the bot is to have something which can be adjusted easily so give it a try and let me know how it works!
Step 9: Last Steps
The speech recognition portion of the app is good but not great. You may have to adjust some of the if statements in the Arduino code to account for words which the speech recognizer misunderstands. For example, I found "sit" often gets interrupted as "set". Simply adding this condition to the info statements in blueControl() can fix this.
Use the printAll() function in the Arduino code to see what the app is sending to help you adjust your code.
One last step I would do is to add a 9 volt battery in order to power the Arduino Nano instead of using the USB supply. There are a few ways to do this but basically you need to connect the positive end of the 9 volt to the Nano's Vin pin and the negative side of the battery to the Nano's GND pin.
Below is how I did it. I used a barrel jack and a barrel jack adapter so I could unplug the battery when not in use.
1. Connect a red jumper wire to the DC barrel jack adapter's positive terminal.
2. Connect a black jumper wire to the DC barrel jack adapter's negative terminal.
3. Connect the free end of the red jumper wire to the Nano's Vin pin on the breadboard.
4. Connect the free end of the black jumper wire to a ground line on the breadboard.
5. Use a bit of hot glue to secure the barrel jack adapter into place on the bot.
6. Connect the 9 volt barrel jack adapter to the 9 volt battery.
7. Make sure you have enough room to plug and unplug the barrel jack, then use a bit of hot glue to secure the 9 volt in place.
Step 10: Final Thoughts
This project was the result of months of troubleshooting and experimenting as it was my first big project using Arduino. In the end, I'm very happy with how it came out. I definitely want to add more and am currently working on a version 2. I hope to add more functionality to bot such as turning and object detection.