As always, when you start working with a new component, it’s better to carefully read its manual. Let’s try to find the data sheet of our new electric circuit. Let’s take this one, for instance, enlarge it a bit and look at the micro circuit. Let me remind you that pins are numbered starting from this notch in the counterclockwise direction. As you might already know, this micro circuit controls heavy loads supplied to the motors with a signal from Arduino. Thus, we need to connect the power supply to this pin. Let me mark it this way. We will connect the minus of the power supply to one of the four ground outputs. Like this. Then we need to connect this output – the logic supply - to Arduino’s 5V output. You will obviously need to connect it to Arduino’s
ground too. We then can control the motors, and our micro circuit allows us to control two motors at once. You need to connect your motors to these outputs, marked in this data sheet with letter Y. These are outputs for one motor, and these ones are for the other one. [DRAWING] Finally, we need to connect the control flow. As we already know, we can control the speed and the direction of motor rotation. To control the speed, we use the pins called “enable”: this one and that one. We will be regulating the speed, just like we were regulating LED brightness. In other words, we need to use those Arduino’s pins which support impulse ration modulation. Let me mark this with a squiggle. [DRAWING] Now I only need to specify the direction of
motor rotation. When you look at the micro circuit, you will understand why we use two pins here marked with letter A. They are compatible with any Arduino’s digital pins for both motors. By inputting a combination of boolean ones and zeros, we can change the direction of motor rotation. Thus, 01 will signify turning in one direction, whereas 10 will
mean turning in the opposite
direction. Besides, let’s see what will happen if we input the combination of 11. With the 00 combination, naturally, nothing will happen. To sum up, we now know how to connect a motor to a controller with a motor driver. Now let’s put this all to practice. Let’s take the power supply and connect it to the board through
the terminal block. Then with the help of these two wires we connect it to the micro
circuit: the red wire or the plus goes to input 8, while the blue wire or the minus goes to the
“ground”. Then we connect the motor itself. Both of its outputs are connected to the circuit’s output from one
side. Then we take the controller and connect it to the 5 V output of the logic supply of the micro circuit. We take the “ground” and we connect it to L293 ground. We then connect 3 Iskra’s pins to the micro circuit: the green wire connects pin 5 to the “enable” pin of this motor, while two other wires on the controller connect digital pins 3 and 4, with the “input” of the micro circuit. Thus, we have connected one motor. We connect the second one in the same way, following the manual. Now let’s see how it works. Let’s see what we have in the test sketch. Firstly, we have created 3 macrodefinitions for the controlling pins: we have connected “enable” to pin 5. We also have two inputs on pins 3
and 4. We have then turned them into outputs. The main thing is: in order to run the motor, we need to apply a combination of low and high level voltage on the
input, which we will name
respectively IN1 and IN2. In our case, we’ve written HIGH and LOW. With the help of analogWrite, we have set the speed, and in our case, this was the maximum speed of 255. To see the effect, we can use a 2-second delay. Then we shall change the direction. Let’s apply the LOW value instead of HIGH on input 1, and on input
2 vice versa – HIGH instead of LOW. The speed will stay unchanged — 255. We will use the delay gain to see how this works. If we want to stop the motors, we should apply low data value or LOW/LOW on both inputs. Look here: despite the fact that the speed still stays at its
maximum, the motor nevertheless stops. To witness this, let me use another delay. Let’s see how it works. [NOISE] [NOISE] Everything works correctly: the motor rotates for 2 second in one direction, then for 2 seconds in the opposite direction, and for 2 seconds it doesn’t move. Now let’s experiment with speed control. For this, we will have to change our sketch a bit. The beginning stays the same, because the connection hasn’t changed. We are sending a combination to the input for rotation in one of the
directions. We shall be increasing the speed in our loop from 0 to the maximum, 255,
by a single unit. Next, with the help of analogWrite, we shall transmit the counter values to “enable” and use the delay to witness the effect. Now let’s choose the opposite direction and create one more cycle, where we will be reducing the speed from its maximum value to 0 unit by unit, and let’s see what happens afterwards. [NOISE] [NOISE] [NOISE] [NOISE] As we expected, the motor accelerates swiftly, and then it starts to rotate in the opposite direction lowering its
speed gradually. You might have noticed that it didn’t start rotating at once. Thing is, low voltage at the beginning is not enough for the motor to break the force of static friction, whereas when the motor rotates in the opposite direction, its speed reduces from the maximum value to 0, and it rotates more
slowly. Don’t forget that a lot of different factors influence the speed of motor rotation: for instance, the reduction ratio used with this motor. Try to bear in mind that with the same speed value that we set, the motor will behave differently depending on the battery charge
level.