An Arduino pin can be rated up to 5 volts and 40 mA, which is insufficient to move a motor. So it will be necessary to incorporate a driver to amplify the current and make the plate can move the motor.
If you want to know how to program it, we invite you to continue reading. We will explain what type of motor you can program and which models you should use.
But that’s not all, you will also find the steps you must do to program a motor from scratch. Don’t miss out on anything and starts with the best motorized projects.
Can any motor be programmed on any Arduino board?
An Arduino board doesn’t have enough power to drive a motor (as we mentioned in the introduction in the first lines of this post), so you will need an amplifier that allows an actuator to be moved. The motors that you can use in Arduino are those of DC type, servomotor, Brushless DC motor, L293D driver, L298 driver, L298N Breakout Board, Shield motor. Within this list are the current amplifiers so that the actuators can work correctly.
Types of motors to use in Arduino What are all that exist?
You can choose the following engines for your projects for you to use in a Arduino board.
Meet each of them in their details:
DC motor
It is a direct current motor, which is also called DC for being direct current. Its main characteristic is to convert electrical energy into mechanical energy by means of a magnetic field. This means that the motor rotates constantly in both directions, if the polarity of the current is changed.
It is composed of a stator; which serves to generate the poles and is generally built with magnets or copper wires; and by a rotor. This last component is the one that receives the direct current and is manufactured in a cylindrical way by graphite or other alloys. Its main use is line motors, stepper motors and servo motors. It is very common to find them in toys because its speed can be controlled.
Servo motor
Servo motor it is a special type of motor that is used to keep the shaft in one place, in this way they can be rotated 180 ° or made a complete turn. It is characterized by having a large torque that it is generated by its potentiometer, which works with a DC motor and is used to move the gears.
Thus, a servo motor is a box that is made up of an Arduino board, a potentiometer, a DC motor and gears. It is used mainly in robotics, so it can be seen in factories, toys and even in elevators.
Driver L293D
The job that this device has is to control other motors, so it becomes an ideal piece for projects of Arduino. It can work with 4 DC type motors or with 2 stepper motors or, if you prefer, with 2 servomotors. Which implies that there may be a combination of these, as allowed by your terminal blocks. By including 4 circuits individual you can control the type of load that will receive each motor.
It can be used on an Arduino UNO board according to these pins:
- Digital 3 – PWM_Motor2
- Digital 4 – DIR_CLK
- Digital 5 – PWM_Motor4
- Digital 6 – PWM_Motor3
- Digital 7 – DIR_EN
- Digital 8 – DIR_SER
- Digital 9 – Servo_1
- Digital 10 – Servo_2
- Digital 11 – PWM_Motor1
- Digital 12 – DIR_LATCH
Driver L298
This component It is in charge of controlling the speed and the direction in which the motors will rotate when they are running. It is characterized by being compatible with a wide range of operating temperatures, 20 ° C ~ + 135 ° C. The output current generated per channel can be up to 2 amps.
The connection of the pins is as follows:
- Pin IN1 – ENGINE A
- IN2 pin – ENGINE A
- Pin IN3 – ENGINE B
- Pin IN4 – ENGINE B
- ENA pin – PWM
- ENB pin – PWM
Brushless DC motor
It is also known as a brushless motor because it does not need slip rings to produce a change of polarity. It is characterized by being light, not need much maintenance Y be cheaper in their manufacturing cost.
The complexity of its handling It has been decreasing in recent times, so it is a widely used tool in technology. To find it correct polarity magnetic field detection is used by means of the rotor. Its mechanism can be found in trays of DVD players and disc coolers.
What should I keep in mind when choosing the ideal motor for my Arduino project?
Before choosing a motor for your Arduino project, you should take these factors into account:
- The speed of the spin time. That is, you will have to interpret what is the optimal speed that the motor needs for your project.
- The force applied to the mass, also know as torque on rotary engines. You must take into account whether the weight of the object you want to move is greater or less than the capacity that the motor will have to move it.
- Ability to deliver the electrical charge. That is, you must consider the amount of energy that the motor is capable of giving in a given time.
- Maximum possibility of work. This is related to the load that the motor has to work without breaking due to the effort it makes.
- The level of precision It is another factor to take into account, since the movements that you will need in your project may require more or less precision.
- Supply voltage. In the electronic part it is important that you know that a motor works at different voltages, so the Arduino board has to offer the same voltage rating.
- Rated current. This element refers to the current intensity that the motor needs to work. Resistance and nominal voltage must be taken into account to establish the logical operating values.
- Energy absorbed by the motor on a certain moment. This is what is known as electrical power and it measures the overall performance of the motor on the Arduino board.
In addition to the values mentioned, you will have to consider, dimensions engine to see if it will fit in place, brackets for fixation, weight and service life, among other factors. By this we mean that to choose the ideal motor in your Arduino project you must take into account many factors, as you can find an actuator that has a higher value than another, which does not imply that it is the best or the right one for you.
Learn step by step how to program a motor in Arduino from scratch
To program a DC Brushless motor in Arduino with variation of speed and rotation you will have to do this step by step:
Assemble all the components
The first thing you will have to do is connect the Arduino with the controller, then the battery to the controller and the latter to the motor. You should not forget that all this you will have to join by means of cables. You can select the type of power you want, that is, if you want 5 or 12 volts. For this you will have to use a jumper to directly access the Arduino board. Then you will have to connect pin 3 and pin 4 with the female cable ends you used.
Assign the coils to the pins
Knowing that the stepper motor has a maximum torque movement, that is, in each step it uses 2 coils, achieving the maximum consumption; a minor pair, since you can choose one coil at a time and obtain moderate consumption; and a half step movement, which is the combination of both situations. It will then be necessary to assign the coils to the pins.
For this you will have to use:
- Pin 8 – COIL A
- Pin 9 – COIL B
- Pin 10 – COIL C
- Pin 11 – COIL D
Program the motor
What you will have to do now is manually program the motor.
For this you will have to enter the configuration and perform these steps for a normal movement:
The codes to program a minor pair are:
While you must enter these codes so that the motor performs the half step movement:
Best Motorized Arduino Projects You Can DIY From Scratch
The best motorized Arduino projects can be found in this list:
Brushless DC motor control
You will need for this project an Arduino Nano board of type R3, then a Brushless DC motor Y propellers to attach to the actuator.
The transmitter codes are:
You will need to use the following programming codes for the receiver:
Motor with potentiometer
For this motorized arduino project you will need to an Arduino UNO board, a engine, a rotary potentiometer, a insert plate, resistance 10K ohms, LEDs Y cables.
Once all the components are joined, you will have to enter these codes:
L293D motor controller
In a plate L293D you will be able to create this project in which you will need an 8-position header for a row, terminal block, a 36-position single-row male, and a plate Nano size and R3 type Arduino.
You are going to have to assemble all the components and then enter these codes into the Arduino IDE: