Create an Arduino robot with our kit

Arduino Robot

With cheap and easy-to-handle material, we are going to assemble a robotic base controlled by Arduino and can be programmed to control the two motors that guide the robot at will. In addition, over time you can add new gadgets to your Arduino robot to advance in the field of robotics or mechatronics.

The mechatronics is a type of engineering that encompasses other types of engineering, such as mechanical, electronic, control and computer engineering. In short, it is used to create automatic or intelligent mobile machines. After all, this is what we do when we work with programming, electronics and mechanical elements (actuators, motors, gears, wheels, ...).

In this article we will explain step by step how to assemble, connect and program the whole assembly for the robotic base. So, if you have never had contact with robots before, you will learn how they work in the simplest way.

Materials needed

  • Arduino board available in our shop.
  • Robot starter kit available in our shop.
  • Motor controller HG7881CP from LC Technology Inc. which is included in the kit. (Download Datasheet)
  • One-wire cable to make the connections between the Arduino and the robot.
  • And as tools for the assembly I used a simple tin soldering iron (and tin wire for soldering) and the screwdriver that comes with the kit.

Introduction to the kit material

In the robot kittogether with the motor controller, make up the basic material for the construction. The kit contains various components that I will introduce to you first of all so that you can keep them in mind.

Contents of the robot kit

  1. One of the things coming up is a practical screwdriver The screwdriver can be used for the assembly and disassembly of all integrated screws and bolts or for further work. The screwdriver is a double-ended screwdriver, so that you can use a flat head or a Phillips head at any time.
  2. You will also see four threads or single-wire cablestwo red and two black. These will be used for soldering to the DC motor assemblies that are also supplied.
  3. The platformmade of transparent methacrylate, is covered with a brown paper protector that you can remove at any time. This will serve as a structural support to attach all the other components, i.e. it is the chassis of our robot. It comes already drilled for easy assembly, with extra holes for other possible future assemblies and extensions.
  4. The two engine assembliesas I have called them, are actually two small DC motors that transmit their power to internal plastic gears (inside the yellow housing) to transform the rotary motion of the motor into a transverse motion of the white shaft that we see protruding from both sides. In addition, the internal gears act as speed reducers to avoid transmitting too many RPMs to the wheels. The motors can operate on a wide range of voltages, but always DC.
  5. The two wheels will be in charge of moving the base thanks to the power transmitted by the motors. They are very easy to assemble, as they fit perfectly on the shafts of the motors.
  6. Another of the components that make up the kit is the Rack for 4 AA batteries that will power the motors. The rack places the batteries in series, which allows the voltage of each of the batteries to be added together to achieve more power for the motors.
  7. Finally you will find a small plastic bag with screws and nuts for assembly, as well as two small wheels to place on the internal axles of the motors and that will serve to put a revolution counter and better control the robot, and two metal brackets that will hold the motors to the platform. The idler wheel will also serve as a steering wheel and as a support point for the front part of the platform.
  8. The engine controller double will allow us to control the motors in conjunction with Arduino. This motor controller has two circuits, one for each motor (or a single phase with 4 lines for 2-stage motors). It also has two HG7881 controller chips. The small board supports currents of 800 mA and can operate with voltages between 2.5 and 12v (always DC).

Assembly of the Arduino robot kit

Once you know what is available to you, it is time to start to assemble it:

  • I wanted to start with the most "complicated", so to speak, as it is not difficult at all. It just takes a little more time. I am referring to soldering the cables One red and one black to each motor. One red and one black for each motor. To do this, I heated up the soldering iron and with a little bit of tin I soldered the solder. I wanted to do it before anything else, because this way with the motors disassembled it is easier to access them than later once they are assembled.
  • The next thing I have done is attach the castors which come in the same bag as the nuts, bolts and idler wheel. The white plastic shaft is simply pushed into the centre groove of the rev counter with a little pressure.
  • Then with the longer screws supplied in the kit we fasten both of them together metal brackets that are included with the motor assembly. As you will see, the yellow motor casing has through holes drilled in the same side where the wheels have been fitted. Put the screws through them and tighten them with a screwdriver.

Robot motor cables

Note: A small tip for soldering, you will see that they come with a transparent plastic that holds them to the yellow part, so remove it a little to the opposite side to where you are soldering so that it does not melt with the heat. And if it is the first time that you weld, verify that the weld has been well (without sticking, breaks,...) and of a bright colour (if the metal has a matt aspect it means that you have made a cold weld, at a lower temperature than the optimum and it is of a worse quality).

  • Now on the other end of the white plastic shaft protruding from the motor assembly, we place the wheels that are included in the kit. They fit the same as the small ones, so it's simple. Once they are attached, we will proceed to attach them to the methacrylate support, just like the idler wheel. The process is simple with four short screws (two for each metal support) we are going to attach the motors to the platform by passing them through the parallel holes that are closer to the two cross-shaped slots in the platform. The idler wheel is screwed with another four screws and four threads to the four front holes (it only fits in one way, as it is not a square, but a rectangle).

Motor cables placed on the robot

Note: Make sure that the inner wheels do not rub against the cross-shaped slots in the platform, otherwise the motors will lose effectiveness due to friction. As you can see in the picture, I have used two of the holes just in front of the motor to pass the wires upwards to facilitate the connections to the Arduino and the motor controller.

  • Finally I have fastened the rack of the batteries to the platform. Put the rack at one end of the platform, I have used the two holes closest to the idler wheel. The reason is to leave more space in the middle to place the Arduino board and the motor controller. Just a tip, you can assemble it your own way... By the way, the assembly is simple, two screws and two nuts.

Robot battery rack

Note: I have put the corner of the cables towards the inside. It seems silly, but this way we won't have to run the cables from one side to the other to make the connections. You will also see that the rack comes from the factory with the black cable coming out of the top slot and the red cable coming out of the bottom. I have passed the red cable carefully so as not to break it into the slot where the black cable comes out. Why? Simple, tightening the rack with the nuts and bolts puts pressure on it and can end up cutting the red wire. To avoid these problems it is better to pass it through the top.

To finish this part, what he has done is to put four AA batteries (the normal ones: LR06 of 1.5v) in the rack and with the wires that come out of the rack I have touched the two wires that we soldered before to the motor for check that it works and it doesn't graze anything.

Note: Black to black and red to red, in DC systems you have to be careful with the poles because you can damage some devices if you don't respect the signs, in this case it is a motor and if you do it the other way round nothing happens, you only reverse the direction of the shaft rotation by reversing the voltage, you will learn more about this when we deal with the motor controller.

By the way, keep all the spare nuts and bolts, you may need them if any of them get lost in the future or if you want to expand the platform with new sensors.

Wired Arduino robot front end

We have already explained how to assemble the kit, now we need to talk about the motor controller, wiring and programming the Arduino to make it work.

It should also be noted that the possibilities of the Arduino robot kit are infinite, as many as you can imagine. By adding proximity sensors you can create an autonomous robot that can move anywhere without colliding with anything, capable of changing direction on its own. You can create a hoover robot with some motors and accessories that you can build yourself, you can make a remote-controlled robot using bluetooth or RF shield from Arduino and so on.

But first, let's get the base ready to work...

Connection to DC motor controller

The plaque Arduino cannot directly manage or control DC motors. Even if we were to make a sketch to give voltage to the motor or remove it thanks to the Arduino outputs, in reaction to certain parameters, the 20mA it provides is not enough for these motors. But that's not what we want for our robot and that's why we need the motor controller.

The cc engines motors that come in the kit can work perfectly well with 6v and about 300mA, as there are two motors, the current demand will be double that, 600mA. Our HG7881 contorlator from LC Technology can operate between 2.5v and 12v, with currents of 800mA. So it's perfect for what we want, plus it's good that it supports up to 12v, as remember that the rack positions the batteries in series and supplies a total voltage of 6v (1.5v x 4 batteries) when the batteries are at the beginning of their life (maximum charge). This is very important, as with voltages below 6v, the motor cannot run at full charge.

With the driver HG7881 is enough for our platform, it is also compact to save weight and space on our robotic platform. It is also advisable to leave it in an open space and not next to other elements that produce heat, some elements of the motor drivers tend to heat up due to the power they handle.

The connection of the motor cables to the driver or motor controller is simple. If you look on the controller board there are two green plastic modules with two screws each. These are splice tabs to connect the motor wires to them. The connection is simple, with the fantastic screwdriver from the kit you loosen the screws a bit and insert the wires of the motors as shown in the following image. Then you tighten the screws and that's it.

Controller connections for the robot

Note: I have used one of the holes in the platform and the screws and nuts that were left over to attach the driver to the platform, as this also has holes in it. I used only one screw/nut and one of the central holes between the cross-shaped holes.

In the image above you can also see a schematic of the pins of the driver connection. As you can see, the two central ones are the power supply wires, Vdc for voltage and GND for ground. The wires from the battery rack should be connected here. In order not to leave the driver unused in case we want to use it for other experiments, we can use jumpers (the option I have chosen) to trap the wire in the pin or make a connection by simply winding the wire. If you want, you can solder it as we did with the motor wires, but to replace it or use it in another application will be more difficult...

With a crimping machine (If you have one, or if you don't, with a pair of scissors, you can remove the insulating wrapping from the battery rack wires to leave a little more bare wire to wrap around the central pins. Also, it is better to leave them like this so that you can remove them at any time and interrupt the supply, unless you have a switch to disconnect the supply, otherwise you will not be able to stop it unless you remove the batteries.

Connection of the robot jumpers

Note: If you want to solder them because you think it is better and you are not going to use the dirver for other purposes, you can do it and if you don't have a switch, an easy and quick way to disconnect the device is by means of a thin plastic sheet, placing it between the negative electrode of the battery and the metal contact of the rack to interrupt the flow of electricity.

Arduino connection and programming

All that remains is to write the source code of our sketch and make the connections between the motor controller and the Arduino. What we will do next is to connect the Arduino pins and the pins on both sides of the controller that have been left free with more single wire.

I have chosen this configuration, if you prefer you can create your own, but don't forget to rectify the source code so that they match with the pins you have used. From the Arduino digital outputs I have chosen 9 and 5 for A-IA and A-IB respectively, while for B-IA and B-IB I have selected 10 and 6. These pins of the motor controller are the ones that will give the speed and direction to the motor. The A-IA and A-IB pins will control motor A (note that next to the green connector pins where you have connected the wires coming from the motors, on the board there is an instruction that says Motor A), while B-IA and B-IB control motor B. Connect the wires in this way and you can say that it is physically finished.

If the Arduino sends a low signal to the A-IA pin and a high signal to A-IB, the motor turns in one direction as it would if A-IA is high and A-IB is low. See how easy it is to control the direction of the motors? This is true if we connect them to normal digital pins, but if we connect them to digital pins, we can control the direction of the motors. PWM pins of the Arduino (remember that they are those with the ~ symbol), we can also control the speed of the motors. That's why I chose the PWM pins in this example.

Without the engine controller We could only give power to one or the other motor or take it away and if we wanted to change the direction we would have to reverse the placement of the wires. To change the speed we would have to play with different batteries or voltages... As you can see, it is not very practical and that is why the motor controller opens up a whole new world of possibilities.

Now let's go to the code of the Arduino sketch that we will write in the environment Arduino IDEwhich is basically as follows:

[cpp]

//Controlling robotic platform engines by ComoHacer.eu

//Declare constants for the PWM pins

const int AIA = 9;  //Pin 9 connected to A-IA
const int AIB = 5;  //Pin 5 connected to A-IB
const int BIA = 10; //Pin 10 connected to B-IA
const int BIB = 6;  //Pin 6 connected to B-IB

//Changes the speed thanks to PWMs varying from 0-255

byte speed = 255;

void setup()
{
pinMode(AIA, OUTPUT); //Configuration of pins as outputs
pinMode(AIB, OUTPUT);
pinMode(BIA, OUTPUT);
pinMode(BIB, OUTPUT);
}

//Main loop with directions: forward, backward, left and right.
//What you are going to do in this case is to move the robot in each direction for 1s,
//you can modify this as you like or add sensors so that depending on data
//captured by the sensor to move accordingly.

void loop()
{
adelante();
delay(1000);
back();
delay(1000);
left();
delay(1000);
right();
delay(1000);
}

//Configuration of each address for the controller to do it

void back()
{
analogWrite(AIA, 0);
analogWrite(AIB, speed);
analogWrite(BIA, 0);
analogWrite(BIB, speed);
}

// If you notice, to change the direction of rotation it is just the opposite of the previous one

void forward()
{
analogWrite(AIA, speed);
analogWrite(AIB, 0);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
}

void left()
{
analogWrite(AIA, speed);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, speed);
}

void derecha()
{
analogWrite(AIA, 0);
analogWrite(AIB, speed);
analogWrite(BIA, speed);
analogWrite(BIB, 0);
}

[/cpp]

What is the maximum speed our Arduino robot can reach?

Contribution to the article by Jose Antonio Navarro.

Our platform is powered by four 1.5 Volt batteries, which gives us a voltage of 6 Volts to power our motors. Well, if we feed directly from the batteries to the motor, we can calculate the maximum speed that our robot will be able to reach. Let's see how:

  1. We measure the revolutions per minute produced by our motor. To do this, once the platform is mounted, we stick a small piece of tape on the edge of the wheel, we raise the platform so that it does not move across the table and we connect the motor to the batteries (remember that they must be at maximum charge so that the calculations are accurate). Using a stopwatch, we count the number of turns the wheel makes in a given period of time, say 30 seconds or 1 minute (obviously this is possible because we have a motor with a large gearbox and the revolutions it produces are relatively few). In our case, I moved my finger slightly closer to the wheel, without touching it, and I counted the number of taps the tape made on my finger, while looking at the stopwatch. I repeated this operation several times to make sure I didn't make any mistakes and then I averaged the three measurements. That gave me a value of 115 revolutions in 30 seconds.
  2. We measure the diameter of the wheel, which is about 66 mm, so the perimeter or length of the circumference of the wheel is:

l = 2 * pi * r

l = 2 * 3,14 * 33

l = 207.24 mm or 20.7 cm

  1. If we have already seen that our wheel rotates at 115 revolutions every 30 seconds, this means that it rotates at:

115 / 30 = 3.83 rev/sec.

  1. If each revolution moves forward by 20.7 cm, our robot will travel 20.7 cm every second:

20.7 * 3.83 = 79.28 cm/sec.

  1. Or, in other words, the same thing:

79.28 * 60 / 100 = 47.57 m/min. (metres per minute)

  1. Or, in other words, the same thing:

47,57 * 60 / 1000 = 2.85 km/h

Note: These calculations are made with no load and, as I mentioned before, with the batteries at maximum charge. When everything is assembled and resting on the surface, the speed will be somewhat lower as it will have to move all that weight.

I hope you liked it and find many applications for it. If you have any questions, please do not hesitate to contact us in the comments.

39 thoughts on “Crea un robot Arduino con nuestro kit”

    1. Alberto Navarro

      Good morning Alfredo!

      We have made several changes to the kit, maybe when you bought it we didn't send it as a set (with a lower price).

      If you look at it now we have it in a much more complete format.

      Greetings!

  1. Sorry, your motor controller is equal to, better or inferior to the
    Motor Controller HG7881CP

    1. Hello Alvaro,

      The motor controller included in the robotics kit is similar to the HG7881CP.

      Best regards and thanks for following us.

Leave a Comment

Your email address will not be published.

en_GBEnglish
Scroll to Top