How to Build a Robot at Home
Gather your components., Flip the battery pack over so that the flat back is facing up., Align the two servos on the end of the battery pack., Affix the servos with your tape or glue., Affix the breadboard perpendicularly on the open space on the...
Step-by-Step Guide
-
Step 1: Gather your components.
In order to build a basic robot, you'll need several simple components.
You can find most, if not all, of these components at your local electronics hobby shop, or at a number of online retailers.
Some basic kits may include all of these components as well.
This robot does not require any soldering:
Arduino Uno (or other microcontroller) 2 continuous rotation servos 2 wheels that fit the servos 1 caster roller 1 small solderless breadboard (look for a breadboard that has two positive and negative lines on each side) 1 distance sensor (with four-pin connector cable) 1 mini push button switch 1 10kΩ resistor 1 USB A to B cable 1 set of breakaway headers 1 6 x AA battery holder with 9V DC power jack 1 pack of jumper wires or 22-gauge hook-up wire Strong double-sided tape or hot glue -
Step 2: Flip the battery pack over so that the flat back is facing up.
You'll be building the robot's body using the battery pack as a base. , This should be the end that the battery pack's wire is coming out of The servos should be touching bottoms, and the rotating mechanisms of each should be facing out the sides of the battery pack.
It's important that the servos are properly aligned so that the wheels go straight.
The wires for the servos should be coming off the back of the battery pack. , Make sure that they are solidly attached to the battery pack.
The backs of the servos should be aligned flush with the back of the battery pack.
The servos should now be taking up the back half of the battery pack. , It should hang over the front of the battery pack just a little bit, and will extend beyond each side.
Make sure that it is securely fastened before proceeding.
The "A" row should be closest to the servos. , If you attached the servos properly, there should be a flat space made by them touching.
Stick the Arduino board onto this flat space so that the Arduino's USB and Power connectors are facing the back (away from the breadboard).
The front of the Arduino should be just barely overlapping the breadboard. , Firmly press the wheels onto the rotating mechanism of the servo.
This may require a significant amount of force, as the wheels are designed to fit as tightly as possible for the best traction. , If you flip the chassis over, you should see a bit of breadboard extending past the battery pack.
Attach the caster to this extended piece, using risers if necessary.
The caster acts as the front wheel, allowing the robot to easily turn in any direction.If you bought a kit, the caster may have come with a few risers that you can use to ensure the caster reaches the ground. , You'll be using these to connect the servos to the breadboard.
Push the pins down through the header so that the pins come out in an equal distance on both sides. , Make sure that they are firmly inserted. , This will connect the servos to the breadboard.
Make sure the left servo is connected to the left header, and the right servo to the right header. , Make sure you use the red rail on the back of the breadboard (closer to the rest of the chassis). , Make sure that you use the blue rail on the back of the breadboard.
Do not plug them into the red rail pins. , This will allow the Arduino to control the servos and turn the wheels. , It does not get plugged into the outer power rails on the breadboard, but instead into the first row of lettered pins (J).
Make sure you place it in the exact center, with an equal number of pins available on each side. , This will ground the sensor. , This will power the sensor. , This will feed information from the sensor to the microcontroller. , Orient it so that the battery pack cable is coming out to the left at the bottom. , Make absolutely sure that the battery pack is oriented correctly. , These two cables will help provide the correct voltage to the Arduino. , The black cable should be plugged into the blue rail pin at pin
30.
The red cable should be plugged into the red rail pin at pin
30. , Connect it at pin 28 on the blue rail. , Do not connect the red rails, as you will likely damage the Arduino. , This will provide the power to the Arduino. , This switch will allow you to turn off the robot without having to unplug the power. , This will power the button. , Connect it to the pin directly next to the black wire that you connected a few steps ago. , This will allow the Arduino to register the push button. , This is the Arduino development environment, and allows you to program instructions that you can then upload to your Arduino microcontroller.
You can download it for free from arduino.cc/en/main/software.
Unzip the downloaded file by double-clicking it and move the folder inside to an easy to access location.
You won't be actually installing the program.
Instead, you'll just run it from the extracted folder by double-clicking arduino.exe. , Plug the battery back jack into the connector on the Arduino to give it power. , Windows will likely not recognize the device. , This will launch the Device Manager. , If you don't see this option, click "Properties" instead, select the "Driver" tab, and then click "Update Driver."
This will allow you to select the driver that came with the Arduino IDE. , You'll find a "drivers" folder inside. ,, You'll be greeted with a blank project. , The code below will make your Arduino continuously move forward. #include <Servo.h> // this adds the "Servo" library to the program // the following creates two servo objects Servo leftMotor; Servo rightMotor; void setup() { leftMotor.attach(12); // if you accidentally switched up the pin numbers for your servos, you can swap the numbers here rightMotor.attach(13); } void loop() { leftMotor.write(180); // with continuous rotation, 180 tells the servo to move at full speed "forward." rightMotor.write(0); // if both of these are at 180, the robot will go in a circle because the servos are flipped. "0" tells it to move full speed "backwards." } , Click the right arrow button in the upper-left corner to build and upload the program to the connected Arduino.
You may want to lift the robot off of the surface, as it will just continue to move forward once the program is uploaded. , Add the following code to the "void loop()" section of your code to enable the kill switch, above the "write()" functions. if(digitalRead(2) == HIGH) // this registers when the button is pressed on pin 2 of the Arduino { while(1) { leftMotor.write(90); // "90" is neutral position for the servos, which tells them to stop turning rightMotor.write(90); } } , With the kill switch code added, you can upload and test the robot.
It should continue to drive forward until you press the switch, at which point it will stop moving.
The full code should look like this: #include <Servo.h> // the following creates two servo objects Servo leftMotor; Servo rightMotor; void setup() { leftMotor.attach(12); rightMotor.attach(13); } void loop() { if(digitalRead(2) == HIGH) { while(1) { leftMotor.write(90); rightMotor.write(90); } } leftMotor.write(180); rightMotor.write(0); } -
Step 3: Align the two servos on the end of the battery pack.
-
Step 4: Affix the servos with your tape or glue.
-
Step 5: Affix the breadboard perpendicularly on the open space on the battery pack.
-
Step 6: Attach the Arduino microcontroller to the tops of the servos.
-
Step 7: Put the wheels on the servos.
-
Step 8: Attach the caster to the bottom of the breadboard.
-
Step 9: Break off two 3-pin headers.
-
Step 10: Insert the two headers into pins 1-3 and 6-8 on row E of the breadboard.
-
Step 11: Connect the servo cables to the headers
-
Step 12: with the black cable on the left side (pins 1 and 6).
-
Step 13: Connect red jumper wires from pins C2 and C7 to red (positive) rail pins.
-
Step 14: Connect black jumper wires from pins B1 and B6 to blue (ground) rail pins.
-
Step 15: Connect white jumper wires from pins 12 and 13 on the Arduino to A3 and A8.
-
Step 16: Attach the sensor to the front of the breadboard.
-
Step 17: Connect a black jumper wire from pin I14 to the first available blue rail pin on the left of the sensor.
-
Step 18: Connect a red jumper wire from pin I17 to the first available red rail pin to the right of the sensor.
-
Step 19: Connect white jumper wires from pin I15 to pin 9 on the Arduino
-
Step 20: and from I16 to pin 8.
-
Step 21: Flip the robot on its side so that you can see the batteries in the pack.
-
Step 22: Connect a red wire to the second spring from the left on the bottom.
-
Step 23: Connect a black wire to the last spring on the bottom-right.
-
Step 24: Connect the red and black wires to the far-right red and blue pins on back of the breadboard.
-
Step 25: Connect a black wire from the GND pin on the Arduino to the back blue rail.
-
Step 26: Connect a black wire from the back blue rail to the front blue rail at pin 29 for each.
-
Step 27: Connect a red wire from the front red rail at pin 30 to the 5V pin on the Arduino.
-
Step 28: Insert the push button switch in the gap between rows on pins 24-26.
-
Step 29: Connect a red wire from H24 to the red rail in the next available pin to the right of the sensor.
-
Step 30: Use the resistor to connect H26 to the blue rail.
-
Step 31: Connect a white wire from G26 to pin 2 on the Arduino.
-
Step 32: Download and extract the Arduino IDE.
-
Step 33: Connect the battery pack to the Arduino.
-
Step 34: Plug the Arduino into your computer via USB.
-
Step 35: Press .⊞ Win+R and type devmgmt.msc.
-
Step 36: Right-click on the "Unknown device" in the "Other devices" section and select "Update Driver Software."
-
Step 37: Select "Browse my computer for driver software."
-
Step 38: Click "Browse" then navigate to the folder that you extracted earlier.
-
Step 39: Select the "drivers" folder and click "OK." Confirm that you want to proceed if you're warned about unknown software.
-
Step 40: Start the Arduino IDE by double-clicking the arduino.exe file in the IDE folder.
-
Step 41: Paste the following code to make your robot go straight.
-
Step 42: Build and upload the program.
-
Step 43: Add the kill switch functionality.
-
Step 44: Upload and test your code.
Detailed Guide
In order to build a basic robot, you'll need several simple components.
You can find most, if not all, of these components at your local electronics hobby shop, or at a number of online retailers.
Some basic kits may include all of these components as well.
This robot does not require any soldering:
Arduino Uno (or other microcontroller) 2 continuous rotation servos 2 wheels that fit the servos 1 caster roller 1 small solderless breadboard (look for a breadboard that has two positive and negative lines on each side) 1 distance sensor (with four-pin connector cable) 1 mini push button switch 1 10kΩ resistor 1 USB A to B cable 1 set of breakaway headers 1 6 x AA battery holder with 9V DC power jack 1 pack of jumper wires or 22-gauge hook-up wire Strong double-sided tape or hot glue
You'll be building the robot's body using the battery pack as a base. , This should be the end that the battery pack's wire is coming out of The servos should be touching bottoms, and the rotating mechanisms of each should be facing out the sides of the battery pack.
It's important that the servos are properly aligned so that the wheels go straight.
The wires for the servos should be coming off the back of the battery pack. , Make sure that they are solidly attached to the battery pack.
The backs of the servos should be aligned flush with the back of the battery pack.
The servos should now be taking up the back half of the battery pack. , It should hang over the front of the battery pack just a little bit, and will extend beyond each side.
Make sure that it is securely fastened before proceeding.
The "A" row should be closest to the servos. , If you attached the servos properly, there should be a flat space made by them touching.
Stick the Arduino board onto this flat space so that the Arduino's USB and Power connectors are facing the back (away from the breadboard).
The front of the Arduino should be just barely overlapping the breadboard. , Firmly press the wheels onto the rotating mechanism of the servo.
This may require a significant amount of force, as the wheels are designed to fit as tightly as possible for the best traction. , If you flip the chassis over, you should see a bit of breadboard extending past the battery pack.
Attach the caster to this extended piece, using risers if necessary.
The caster acts as the front wheel, allowing the robot to easily turn in any direction.If you bought a kit, the caster may have come with a few risers that you can use to ensure the caster reaches the ground. , You'll be using these to connect the servos to the breadboard.
Push the pins down through the header so that the pins come out in an equal distance on both sides. , Make sure that they are firmly inserted. , This will connect the servos to the breadboard.
Make sure the left servo is connected to the left header, and the right servo to the right header. , Make sure you use the red rail on the back of the breadboard (closer to the rest of the chassis). , Make sure that you use the blue rail on the back of the breadboard.
Do not plug them into the red rail pins. , This will allow the Arduino to control the servos and turn the wheels. , It does not get plugged into the outer power rails on the breadboard, but instead into the first row of lettered pins (J).
Make sure you place it in the exact center, with an equal number of pins available on each side. , This will ground the sensor. , This will power the sensor. , This will feed information from the sensor to the microcontroller. , Orient it so that the battery pack cable is coming out to the left at the bottom. , Make absolutely sure that the battery pack is oriented correctly. , These two cables will help provide the correct voltage to the Arduino. , The black cable should be plugged into the blue rail pin at pin
30.
The red cable should be plugged into the red rail pin at pin
30. , Connect it at pin 28 on the blue rail. , Do not connect the red rails, as you will likely damage the Arduino. , This will provide the power to the Arduino. , This switch will allow you to turn off the robot without having to unplug the power. , This will power the button. , Connect it to the pin directly next to the black wire that you connected a few steps ago. , This will allow the Arduino to register the push button. , This is the Arduino development environment, and allows you to program instructions that you can then upload to your Arduino microcontroller.
You can download it for free from arduino.cc/en/main/software.
Unzip the downloaded file by double-clicking it and move the folder inside to an easy to access location.
You won't be actually installing the program.
Instead, you'll just run it from the extracted folder by double-clicking arduino.exe. , Plug the battery back jack into the connector on the Arduino to give it power. , Windows will likely not recognize the device. , This will launch the Device Manager. , If you don't see this option, click "Properties" instead, select the "Driver" tab, and then click "Update Driver."
This will allow you to select the driver that came with the Arduino IDE. , You'll find a "drivers" folder inside. ,, You'll be greeted with a blank project. , The code below will make your Arduino continuously move forward. #include <Servo.h> // this adds the "Servo" library to the program // the following creates two servo objects Servo leftMotor; Servo rightMotor; void setup() { leftMotor.attach(12); // if you accidentally switched up the pin numbers for your servos, you can swap the numbers here rightMotor.attach(13); } void loop() { leftMotor.write(180); // with continuous rotation, 180 tells the servo to move at full speed "forward." rightMotor.write(0); // if both of these are at 180, the robot will go in a circle because the servos are flipped. "0" tells it to move full speed "backwards." } , Click the right arrow button in the upper-left corner to build and upload the program to the connected Arduino.
You may want to lift the robot off of the surface, as it will just continue to move forward once the program is uploaded. , Add the following code to the "void loop()" section of your code to enable the kill switch, above the "write()" functions. if(digitalRead(2) == HIGH) // this registers when the button is pressed on pin 2 of the Arduino { while(1) { leftMotor.write(90); // "90" is neutral position for the servos, which tells them to stop turning rightMotor.write(90); } } , With the kill switch code added, you can upload and test the robot.
It should continue to drive forward until you press the switch, at which point it will stop moving.
The full code should look like this: #include <Servo.h> // the following creates two servo objects Servo leftMotor; Servo rightMotor; void setup() { leftMotor.attach(12); rightMotor.attach(13); } void loop() { if(digitalRead(2) == HIGH) { while(1) { leftMotor.write(90); rightMotor.write(90); } } leftMotor.write(180); rightMotor.write(0); }
About the Author
Joshua Vasquez
Brings years of experience writing about lifestyle and related subjects.
Rate This Guide
How helpful was this guide? Click to rate: