Sarah the Simplest Arduino Robot
by TechMartian in Circuits > Robots
2344 Views, 21 Favorites, 0 Comments
Sarah the Simplest Arduino Robot
![2016-07-28 17.24.30.jpg](/proxy/?url=https://content.instructables.com/FWN/UQJY/J5MQPDJU/FWNUQJYJ5MQPDJU.jpg&filename=2016-07-28 17.24.30.jpg)
![2016-07-28 17.24.02.jpg](/proxy/?url=https://content.instructables.com/FA3/UXJW/J5MQPDJT/FA3UXJWJ5MQPDJT.jpg&filename=2016-07-28 17.24.02.jpg)
Sarah is a small, quick, and simple Arduino robot for beginner makers. She uses a differential drive to maneuver. She also uses the Dual TB6612FNG, capable of drawing 1 amp, motor driver to control the motion of the two wheels.
I wanted to make a cheap and simple robot for those makers whoa re just getting into the hobby, so as to make something fun to play with without breaking the bank or pouring countless hours into.
Tools and Materials
![2016-07-28 16.25.38.jpg](/proxy/?url=https://content.instructables.com/FQB/PC1Y/J5MQPDBV/FQBPC1YJ5MQPDBV.jpg&filename=2016-07-28 16.25.38.jpg)
Electronics
- Arduino 101 or Arduino Uno
- Breadboard
- Dual TB6612FNG 1 Amp Motor Driver Board
- Jumper Wires
- DC motors and wheels
Chassis
- Foam Board - 15cm x 15cm
- Battery Holder and 8 AA batteries
Tools
- Glue Gun
- Clear Tape
Glue the Motors to the Foam Board
![2016-07-28 16.33.03.jpg](/proxy/?url=https://content.instructables.com/FP3/2K6F/J5MQPDF0/FP32K6FJ5MQPDF0.jpg&filename=2016-07-28 16.33.03.jpg)
![2016-07-28 16.34.26.jpg](/proxy/?url=https://content.instructables.com/FHD/6PAA/J5MQPDF2/FHD6PAAJ5MQPDF2.jpg&filename=2016-07-28 16.34.26.jpg)
![2016-07-28 16.33.54.jpg](/proxy/?url=https://content.instructables.com/FET/BKMN/J5MQPDF1/FETBKMNJ5MQPDF1.jpg&filename=2016-07-28 16.33.54.jpg)
![2016-07-28 16.36.47.jpg](/proxy/?url=https://content.instructables.com/F35/GA14/J5MQPDF3/F35GA14J5MQPDF3.jpg&filename=2016-07-28 16.36.47.jpg)
![2016-07-28 16.38.48.jpg](/proxy/?url=https://content.instructables.com/FXH/K1G2/J5MQPDF4/FXHK1G2J5MQPDF4.jpg&filename=2016-07-28 16.38.48.jpg)
![2016-07-28 16.43.40.jpg](/proxy/?url=https://content.instructables.com/FZ3/1HBE/J5MQPDF9/FZ31HBEJ5MQPDF9.jpg&filename=2016-07-28 16.43.40.jpg)
- Mark the halfway line of the 15x15cm square foam board with a pen.
- Align the centre of the rotating axle of the motor to the halfway line on both sides and glue it with a hot glue gun.
- Attach the wheels to the motor when the hot glue has solidified. It will fit in snuggly.
Making the Pillars
![2016-07-28 16.31.11.jpg](/proxy/?url=https://content.instructables.com/FPV/QXZB/J5MQPDEZ/FPVQXZBJ5MQPDEZ.jpg&filename=2016-07-28 16.31.11.jpg)
![2016-07-28 16.30.42.jpg](/proxy/?url=https://content.instructables.com/F7J/834A/J5MQPDEY/F7J834AJ5MQPDEY.jpg&filename=2016-07-28 16.30.42.jpg)
![2016-07-28 16.41.57.jpg](/proxy/?url=https://content.instructables.com/FVO/WU1V/J5MQPDF7/FVOWU1VJ5MQPDF7.jpg&filename=2016-07-28 16.41.57.jpg)
- Balance the robot on the two wheels and measure the height of the robot below the foam board.
- Cut a foam board sized for the measured height and glue two pieces of it together, to make a pillar.
- Glue the pillars onto the four corners of the robot's base, to make it balance.
Secure the Arduino Board to the Chassis
![2016-07-28 16.47.04.jpg](/proxy/?url=https://content.instructables.com/FJH/UZDC/J5MQPDFA/FJHUZDCJ5MQPDFA.jpg&filename=2016-07-28 16.47.04.jpg)
![2016-07-28 16.47.26.jpg](/proxy/?url=https://content.instructables.com/F66/RE70/J5MQPDFB/F66RE70J5MQPDFB.jpg&filename=2016-07-28 16.47.26.jpg)
- Tape the front edge of the Arduino and breadboard holder to the leading edge of the car, wrapping it around the chassis. Cut off any excess tape.
- Tape the trailing edge of the Arduino and breadboard holder to the foam board chassis and cut off any excess tape.
Adding the Battery Holder
![2016-07-28 16.49.55.jpg](/proxy/?url=https://content.instructables.com/FD9/QZOT/J5MQPDFC/FD9QZOTJ5MQPDFC.jpg&filename=2016-07-28 16.49.55.jpg)
![2016-07-28 16.52.30.jpg](/proxy/?url=https://content.instructables.com/FRK/Y5MX/J5MQPDFI/FRKY5MXJ5MQPDFI.jpg&filename=2016-07-28 16.52.30.jpg)
![2016-07-28 16.54.28.jpg](/proxy/?url=https://content.instructables.com/FQX/A76C/J5MQPDFK/FQXA76CJ5MQPDFK.jpg&filename=2016-07-28 16.54.28.jpg)
![2016-07-28 16.58.47.jpg](/proxy/?url=https://content.instructables.com/FY0/HNMA/J5MQPDFM/FY0HNMAJ5MQPDFM.jpg&filename=2016-07-28 16.58.47.jpg)
- Glue the battery holder with the barrel jack connector to the front of the chassis with the hot glue gun. It will stick out a bit, but that's alright.
- Secure it by further gluing edges of the battery holder onto the chassis with the hot glue gun.
- Place two of the AA batteries on the battery holder with the two exposed wires, and tape these batteries securely to the holder.
- Add two small beads of glue onto the tape holding the battery and adhere it to the breadboard with hot glue.
- Plug in the red wire on the battery holder to the red power rail and the black wire on the black power rail.
- Secure the wires using with hot glue and tape onto the breadboard.
Cable Management
![2016-07-28 16.42.20.jpg](/proxy/?url=https://content.instructables.com/FRC/E6G7/J5MQPDF8/FRCE6G7J5MQPDF8.jpg&filename=2016-07-28 16.42.20.jpg)
![2016-07-28 16.50.47.jpg](/proxy/?url=https://content.instructables.com/FS1/X42D/J5MQPDFE/FS1X42DJ5MQPDFE.jpg&filename=2016-07-28 16.50.47.jpg)
![2016-07-28 17.07.27.jpg](/proxy/?url=https://content.instructables.com/FGL/X274/J5MQPDGF/FGLX274J5MQPDGF.jpg&filename=2016-07-28 17.07.27.jpg)
![2016-07-28 17.07.49.jpg](/proxy/?url=https://content.instructables.com/FAV/UK7B/J5MQPDIT/FAVUK7BJ5MQPDIT.jpg&filename=2016-07-28 17.07.49.jpg)
- Twist the two motors wires together.
- Glue both wires onto the chassis to a length short enough so that the wire does not get caught by the wheels with a hot glue gun.
- Make sure at least one of the batteries is unplugged, then glue the battery holder wires onto the front of the breadboard and Arduino Holder with a hot glue gun.
Wiring the Motor Driver
![Screen Shot 2017-07-30 at 11.37.47 PM.png](/proxy/?url=https://content.instructables.com/FHG/YQCJ/J5MQHM5C/FHGYQCJJ5MQHM5C.png&filename=Screen Shot 2017-07-30 at 11.37.47 PM.png)
![2016-07-28 17.23.48.jpg](/proxy/?url=https://content.instructables.com/FH3/MK0G/J5MQPDIZ/FH3MK0GJ5MQPDIZ.jpg&filename=2016-07-28 17.23.48.jpg)
- Connect the first motor's pins to pins 4 and 5 of the motor driver board.
- Connect the second motor's pins to pins 6 and 7 of the motor driver board.
- Connect the motor driver board's pin 1 to the red power rail and pin 5 to the black power rail.
- Connect the Arduino's pins 8 to 12 to the motor driver board's pins 11 to 15.
- Connect the Arduino's pin 5 to the motor driver boards's pin 10.
- Connect the Arduino's pin 3 to the motor driver board's pin 16.
Coding
![Screen Shot 2017-07-31 at 2.01.17 AM.png](/proxy/?url=https://content.instructables.com/FN8/MJOU/J5MQHL9U/FN8MJOUJ5MQHL9U.png&filename=Screen Shot 2017-07-31 at 2.01.17 AM.png)
The motor driver board uses two pins per motor to control the direction and one pin to control the speed by using PWM signals. In addition to the speed and direction pins, it also has one pin for standby mode, where both motors are not being supplied power and therefore acts as an emergency stop function.
Setting both pins to HIGH or LOW makes the robot stop. To control the direction of the robot using the two direction pins, set one of the direction pins as HIGH and the other direction pin as LOW. To make the motor spin in the opposite direction,
Compile and upload the following onto the Arduino and then remove the printer cable once it is uploaded.
//motor A connected between A01 and A02
//motor B connected between B01 and B02
int STBY = 10; //standby
//Motor A int PWMA = 3; //Speed control int AIN1 = 9; //Direction int AIN2 = 8; //Direction
//Motor B int PWMB = 5; //Speed control int BIN1 = 11; //Direction int BIN2 = 12; //Direction
void setup(){ pinMode(STBY, OUTPUT);
pinMode(PWMA, OUTPUT); pinMode(AIN1, OUTPUT); pinMode(AIN2, OUTPUT);
pinMode(PWMB, OUTPUT); pinMode(BIN1, OUTPUT); pinMode(BIN2, OUTPUT); }
void loop(){ move(1, 255, 1); //motor 1, full speed, left move(2, 255, 1); //motor 2, full speed, left
delay(1000); //go for 1 second stop(); //stop delay(250); //hold for 250ms until move again
move(1, 128, 0); //motor 1, half speed, right move(2, 128, 0); //motor 2, half speed, right
delay(1000); stop(); delay(250); }
void move(int motor, int speed, int direction){ //Move specific motor at speed and direction //motor: 0 for B 1 for A //speed: 0 is off, and 255 is full speed //direction: 0 clockwise, 1 counter-clockwise
digitalWrite(STBY, HIGH); //disable standby
boolean inPin1 = LOW; boolean inPin2 = HIGH;
if(direction == 1){ inPin1 = HIGH; inPin2 = LOW; }
if(motor == 1){ digitalWrite(AIN1, inPin1); digitalWrite(AIN2, inPin2); analogWrite(PWMA, speed); }else{ digitalWrite(BIN1, inPin1); digitalWrite(BIN2, inPin2); analogWrite(PWMB, speed); } }
void stop(){ //enable standby digitalWrite(STBY, LOW); }
Testing
![2016-07-28 17.19.37.jpg](/proxy/?url=https://content.instructables.com/F7A/NHG2/J5MQPDIW/F7ANHG2J5MQPDIW.jpg&filename=2016-07-28 17.19.37.jpg)
![Sarah the Simple Robot Demonstration](/proxy/?url=https://content.instructables.com/FTN/JM86/J5MQHLRK/FTNJM86J5MQHLRK.jpg&filename=Sarah the Simple Robot Demonstration)
- Add the remaining batteries onto both battery holders.
- Connect the barrel jack from the battery holder onto the Arduino to power it.