How To Connect A Brushed Motor To Arduino

Table of contents:

How To Connect A Brushed Motor To Arduino
How To Connect A Brushed Motor To Arduino

Video: How To Connect A Brushed Motor To Arduino

Video: How To Connect A Brushed Motor To Arduino
Video: Brushed motors Arduino drone - Part1 - components 2024, November
Anonim

As you know, there are three main types of electric motors: collector, stepper and servo drives. In this article, we will look at connecting a collector motor to an Arduino using a motor driver based on the L9110S microcircuit or similar.

Motor driver based on L9110S chip
Motor driver based on L9110S chip

Necessary

  • - Arduino;
  • - a personal computer with the Arduino IDE development environment;
  • - motor driver L9110S or similar;
  • - collector electric motor;
  • - connecting wires.

Instructions

Step 1

You cannot directly connect an electric motor to the Arduino pins: there is a risk of burning the pin to which the motor is connected. To safely connect different types of electric motors to the Arduino, a homemade or commercially manufactured motor driver is required. There are many different motor drivers. The most common types are HG788, L9110S, L293D, L298N and others. Motor drivers have power leads, motor leads, and control leads. In this article, we will use a motor driver based on the L9110S microcircuit. Boards are usually produced that support the connection of multiple motors. But for the demonstration, we'll get by with one.

Various motor drivers
Various motor drivers

Step 2

The simplest motors are brushed motors. These motors have only two control contacts. Depending on the polarity of the voltage applied to them, the direction of rotation of the motor shaft changes, and the magnitude of the applied voltage changes the rotation speed.

Let's connect the motor according to the attached diagram. The power supply of the motor driver is 5 V from the Arduino, to control the speed of the motor rotor, the control contacts are connected to the Arduino pins that support PWM (pulse width modulation).

Arduino motor connection diagram
Arduino motor connection diagram

Step 3

Let's write a sketch to control a collector motor. Let's declare two constants for the legs that control the motor, and one variable for storing the speed value. We will transfer the values of the variable Speed to the serial port and thus change the speed and direction of rotation of the motor.

Maximum rotational speed - at the highest voltage value that the motor driver can supply. We can control the speed of rotation by supplying voltages in the range of 0 to 5 volts. Since we use digital pins with PWM, the voltage on them is regulated by the analogWtirte (pin, value) command, where pin is the number of the pin on which we want to set the voltage, and the value argument is a coefficient proportional to the voltage value, taking values in the range from 0 (pin voltage is zero) to 255 (pin voltage is 5 V).

Brush motor control sketch
Brush motor control sketch

Step 4

Load the sketch into Arduino memory. Let's launch it. The engine does not rotate. To set the rotation speed, a value between 0 and 255 must be transmitted to the serial port. The direction of rotation is determined by the sign of the number.

Connect using any terminal to the port, send the number "100" - the engine will start rotating at an average speed. If we give "minus 100", then it will start rotating at the same speed in the opposite direction.

Recommended: