Robotic Rat

by David Galindo in Circuits > Arduino

5880 Views, 34 Favorites, 0 Comments

Robotic Rat

IMG_20190318_203241.jpg

Hello!

My name is David, I am a 14-year-old boy living in Spain and this is my first Instructable. I have been building robots and fixing old computers for some time now and my robotics teacher told me that it was good time to start sharing with other people what I have learnt. So here we go!

One day a friend of mine gave me a 3D model to build a robot and some components: One arduino nano microcontroller and two servo motors, with these 3 things I started to build my little robot.
In this Instructable I am going to share with you how to make this robot, also I will include the 3D model and the code that I have written, so you can have all that it is needed to make your own robotic rat!

What You Need:

IMG_20190318_204623.jpg

- Arduino Nano microcontroller

- 2 SG90 servo motors (You can find them in Amazon, or in some online shops)

- You will have to print the 3D model or you can build a structure with cardboard or plastic. I used this model: https://www.tinkercad.com/things/12eU8UHtMSB from Tinker Robot Labs

- Some wires, and a small breadboard

- A 9 Volt battery and a connector

Also you will need to use the arduino IDE, you can download it in the next link: https://www.arduino.cc/en/Main/Software

Calibrating the Servos

IMG_20190318_212741.jpg
WhatsApp Image 2019-03-24 at 19.15.51.jpeg

Before starting the robot you have to do one previous step. You need to find the middle position of the servo. A servo can turn 180 degrees (half a circumference), and you need to find where is the 90 degree position first to be able to put the legs perpendicular to the body. To do this I wrote a program that puts the servos in the 90º position. Once the servos are at 90º you will have a reference point of where the servo will be at the beginning of the program.

This is the program that I use to center the servos:

#include

Servo Front;

Servo Back;

void setup() {

Front.attach(9);

Back.attach(6);

}

void loop(){

Front.write(90);

Back.write(90);

}

You will have to make small adjustments to the software or the hardware to improve the movement of the robot and get a perfect gait, but first let's make the robot move, and at the end of the project, you will be able to do these adjustments.

Assembling the Legs

IMG_20190318_211015.jpg
IMG_20190318_211054 (1).jpg
IMG_20190318_213058.jpg
IMG_20190318_213353.jpg

After this you have to take the shafts of the servos and put it into the legs of the robot, to make this easier you can cut a little of the material around the hole in the legs to enter there the shafts.

Secondly you will need to screw in the shafts with the 3D legs into the servos, when you have all in the right position, put a little dot of hot glue between the shaft and the legs to secure them in place. Be sure to put the legs at 90 degrees as seen in step 2.

Installing the Servos

IMG_20190318_214151.jpg
IMG_20190318_214203.jpg
IMG_20190318_214246.jpg

Now you have to install the servos in the body of the robot, to do this you have to take the body in one hand and push in the servo, with the legs, into a hole that you have for the servo. Be sure that the wires of the servo goes in the right position, if not the servo will not fit in the chassis. There is a small slot on one of the sides of the servo hole. Use that slot for the wires.

Repeat this step with the other set of legs.

Adding the Arduino

IMG_20190324_173355.jpg
IMG_20190324_173435 (1).jpg
IMG_20190324_174556.jpg

After all these steps you will have the robot hardware finished. Now we are entering in the final part, the electronics and wiring. First, take the Arduino Nano and push it into the breadboard, then you'll have to remove the paper in the bottom side of the breadboard and glue the breadboard in the 3D model.

Wiring

WhatsApp Image 2019-03-24 at 19.43.54.jpeg
IMG_20190324_173529.jpg

Let’s do the wiring! In this step in which you will connect all the wires from the breadboard, to the servos.

All the servos have three wires, so one is for the information that the arduino sends, the orange one, other is for the +5v current, the red one, and finally the GND (or ground) wire, that is the brown one.

To connect the wires you may want to look at the code we have used to center the servos. In the code we can see that the servo for the front legs it is connected to the pin D9 and the other servo, the one for the back legs and tail it is connected in the port D6. this means that the orange wire of the front servo goes to the D9 pin, and the orange wire of the servo for the back legs is connected to the D6 pin. The red cable of both servos go to 5V and the brown wires of both servos go to GND (any of the GND pins of the Arduino Nano).

And Some Code

IMG_20190324_174239.jpg

To finish the robot you have to bring it alive!, so here comes my favourite part, the code.

Here below, I share with you the code. The key to make your robot walk with a perfect gate is to modify the program to perfectly adapt it to the weight and balance of your rat, but I only recommend this if you know a little bit of arduino's programmation. If your rat struggles to walk, write a comment and I can help you to make your rat walk with some style!.

Here you have the code that I used:

#include <Servo.h>

Servo Front;

Servo Back;

void setup() {

Front.attach(9);

Back.attach(6);

Front.write(92); // my front servo, at 90 degrees was not perfectly straight, so I had to modify the angle to 92 degrees.

Back.write(90);

delay(1000); //the robot puts all legs perpendicular to the body and waits one second

}

void loop() {

// This loop will run till you unplug the robot

// You can modify the angles or the delay time between movements to make your robot walk quicker or slower or make bigger or smaller steps

Front.write(132);

delay(100);

Back.write(50);

delay(300);

Front.write(50);

delay(100);

Back.write(130);

delay(300);

}

After writing the program in the arduino's programming platform you can upload it in the robot and see how it moves.

You Are Done!

Robotic Rat (How it walks)

This robot is super simple to assemble, and the program is also quite simple. It is easy to make it move... but quite complicated to make it move gracefully. If you want to start building and programming walking robots, this is a good project for you. You will learn with this project how to program a “gait”, the sequence of instructions to make your robot walk.

I hope you have enjoyed my first instructables and please, if you need any help with your robot, I will be happy to assist you in English, French or Spanish.

David