【 Programming Motor in Arduino 】 Step by Step Guide ▷ 2022

One pin can be rated up to 5 volts and 40 mA, which is insufficient to drive a motor. So it will be necessary to incorporate a driver to amplify the current and make the board 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 what are the models that you should use.

But that’s not all, you will also find the steps you must take to program an engine from scratch. Do not miss anything and start with the best motorized projects.

Can any motor be programmed on any Arduino board?

An Arduino board does not 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 to move an actuator. The engines that you can use in Arduino are those of DC type, Servo motor, 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 the ones that exist?

You may choose the following motors 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 motorwhich is also called DC because it is 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 consists of a stator; which is used to generate the poles and is generally built with magnets or copper wires; and for 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 you can control your speed.

servo motor

the servo motor It is a special type of motor that is used to keep the axis in one place., in this way they can be rotated 180° or make a complete turn. It is characterized by having a great torque that generated by your potentiometerwhich works with a DC motor and is used to move gears.

Therefore, A servo motor is a box that is made up of an Arduino board., a potentiometer, a DC motor and gears. It is mainly used in robotics, which is why it can be seen in factories, toys, and even elevators.

See also  【Edit PDF on MacOS】Step by Step Guide ▷ 2022

Driver L293D

The job of this device is to control other motorsso 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 servo motors.. Which implies that there can be a combination of these, as allowed by their terminal blocks. By including 4 circuits You can control the type of load that each motor will receive.

It can be used on an Arduino UNO board according to these pins:

  • digit 3 –PWM_Motor2
  • digit 4 – DIR_CLK
  • Digital 5 –PWM_Motor4
  • Digital 6 –PWM_Motor3
  • Digital 7 – DIR_IN
  • 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 direction in which the motors will rotate when they are running. It is characterized by being compatible with a wide operating temperature range, 20°C~+135°C. The output current that it generates per channel can reach up to 2 amps.

The connection of the pins is as follows:

  • Pin IN1 – ENGINE A
  • Pin IN2 – ENGINE A
  • Pin IN3 – ENGINE B
  • Pin-IN4 – ENGINE B
  • ENA Pin -PWM
  • Pin ENB -PWM

Brushless DC motor

It is also known as a brushless motor because it does not need slip rings. to produce a change polarity. It is characterized by being light, not need much maintenance Y be cheaper in its manufacturing cost.

The complexity of its management It has been decreasing in recent times, which is why 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 take into account 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 rotated 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 massalso know as torque in rotary engines. You must take into account if the weight that the object you want to move will have is greater or less than the capacity that the motor will have to move it.
  • Ability to deliver electrical charge. That is, you must consider the amount of energy that the engine is capable of giving in a given time.
  • Maximum job opportunity. This is related to the load that the engine has to work without breaking due to the effort it makes.
  • precision level 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 nominal voltage capacity.
  • rated current. This element refers to the current intensity that the motor needs to work. It is necessary to take into account the resistance and the nominal voltage to establish the logical values ​​of operation.
  • Power absorbed by the motor on a certain moment. This is what is known as electrical power and measures the overall performance of the motor on the Arduino board.
See also  【 Create Automatic Replies in Outlook 】 Step by Step Guide ▷ 2022

In addition to the mentioned values ​​you will have to consider, the dimensions engine to see if it will fit in place, the brackets for fixing, weight and useful life, among other factors. By this we mean that to choose the ideal motor in your Arduino project You have to take many factors into account.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 speed and rotation variation 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 to the controller, then the battery to the controller and the latter to the motor. You must not forget that all this will have to be joined 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 coils to pins

Knowing that the stepper motor has a maximum torque movementthat is, in each step it uses 2 coils, achieving the maximum consumption; a minor pairsince 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 engine

What you will have to do now is manually program the engine.

To do this you will have to enter the configuration and perform these steps for a normal movement:

*/ #define IN1 8 #define IN2 9 #define IN3 10 #define IN4 11 int step = { {1, 1, 0, 0}, {0, 1, 1, 0}, {0, 0, 1, 1 }, {1, 0, 0, 1} }; void setup() { pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); } void loop() { for (int i = 0; i < 4; i++) { digitalWrite(IN1, step); digitalWrite(IN2, step); digitalWrite(IN3, step); digitalWrite(IN4, step); delay(10); } }

See also  【 CONVERT JPG Images to PDF 】 Step by Step Guide ▷ 2022

The codes to program a minor pair are:

#define IN1 8 #define IN2 9 #define IN3 10 #define IN4 11 int step = { {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1} }; void setup() { pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); } void loop() { for (int i = 0; i < 4; i++) { digitalWrite(IN1, step); digitalWrite(IN2, step); digitalWrite(IN3, step); digitalWrite(IN4, step); delay(10); } }

While you must enter these codes for the motor to perform the movement of medium step:

#define IN1 8 #define IN2 9 #define IN3 10 #define IN4 11 int step = { {1, 0, 0, 0}, {1, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 1, 0}, {0, 0, 1, 0}, {0, 0, 1, 1}, {0, 0, 0, 1}, {1, 0, 0, 1} } ; void setup() { pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); } void loop() { for (int i = 0; i < 8; i++) { digitalWrite(IN1, step); digitalWrite(IN2, step); digitalWrite(IN3, step); digitalWrite(IN4, step); delay(10); } }

The Best Motorized Arduino Projects You Can Make Yourself From Scratch

The best motorized Arduino projects can be found in this list:

Brushless DC motor control

You will need for this project a then a Brushless DC motor Y propellers to attach to actuator.

The transmitter codes are:

# include < Servo.h > Servo esc; Software Serial hc12 ( 2 , 3 ); // RX, TX int thr, ail, ele, rud; void setup() { attach( 10 ); pinMode(A0, INPUT); Serial. begin( 9600 ); begin( 9600 ); } void loop() { thr = map( analogRead(A0), 0, 1023, 0, 180 ); print(thr); Serial. print(thr); delay(100); }

You will need to use the following programming codes for the receiver:

# include < Servo.h > Servo esc; String input; int throttle, th; void setup() { attach( 10 ); Serial. begin( 9600 ); begin( 9600 ); write( 170 ); delay (2000); write( 90 ); delay (2000); write( 140 ); delay (2000); write( 90 ); delay (2000); } void loop() { if(Serial.available()) { accelerator = Serial. readStringUntil( ‘\n’ ); if (input.length() > 0 ) { write(throttle); delay ( 10 ); } } }

motor with potentiometer

For this motorized arduino project you will need toa engine, a rotary Potentiometer, a insert plate, endurance 10K ohms, leds Y cables.

Once you join all the components you will have to enter these codes:

#define MOF_PIN 6 #define POT_PIN A1 int pot = 0 ; void setup() { pinMode(MOF_PIN, OUTPUT); pinMode(POT_PIN, INPUT); Serial . begin ( 9600…

Loading Facebook Comments ...
Loading Disqus Comments ...