logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

The Basics of Arduino Electronics: Controlling the Motor

Device Plus Editorial Team
Published by Device Plus Editorial Team at March 29, 2020
Categories
  • Arduino
Tags

This article was translated to English, and was originally published for deviceplus.jp.

On Device Plus, a wide variety of applications for Arduino and examples of pieces were introduced, but knowing the basics is especially important whenever you’re creating something. So that’s why for today’s article, we’ll be going over the key foundations of Arduino. Teaching us this today will be expert and author of “Entry into the Basics of Arduino Electronic Crafts!” Kazuhiro Fukuda.

In this article, I would like to cover ways on how you can control motors with large electrical currents.

Motors are used to run a wide variety of machines such as drones and cars. Connecting motors to a power supply makes it possible for electronic components to generate rotational motion. Attaching tires or propellers to a motor also increases the rotation and movement of operations.

On Arduino, it’s possible to control the motor. As with the LED, you can control the motor to rotate or stop by turning the power supplied to the motor on and off. When combined with other sensors, it’s possible to set up automatic control, such as stopping the motor when an obstacle approaches.

control the motor

The motor rotates in the opposite direction when the direction of the connected power supply is reversed. It is also possible to change the rotation speed by adjusting the amount of current to flow. As a result, this makes it possible to rotate at high speed when the motor is moving or to slowly stop at a desired position by gradually slowing down when stopping. Even if a projectile hits the fans, the motor can move backward and move in other directions. That being said, today we’ll be going over ways you can control a motor on Arduino.

[Table of Contents]

・Operating the Motor Requires a Driver

・Connecting the Motor to Arduino

・Controlling the Motor on a Program

・Changing the Rotation Speed of the Motor

Operating the Motor Requires a Driver

On Arduino’s digital output, you can switch between High and Low to control the light flashes of the LED. Using this function, you should be able to supply electricity to the motor. However, even if you actually connect the motor directly to Arduino, it won’t be operable.

In order to move the motor, a large amount of electric current is necessary. For example, for today’s「RE-280RA」, you would need more than 1A of electrical current for it to move. However, Arduino’s digital output connector can only flow up to 20mA. Flowing any electrical current past this could potentially damage the Arduino. To do this, we need to connect the motor to Arduino’s output connector and control it.

operating the motor requires a driver

What will be used here is a「Motor driver」. A motor driver is an electrical component used to control a motor. Prepare a circuit that connects the motor to the power supply for operating the motor and insert the motor driver inside. The motor driver can connect and disconnect the motor operation circuit by an external signal, and can control the rotation and stop of the motor. Since almost no current flows into the control signal, even if the Arduino is connected, it will be possible to control the motor without any problems.

control signal from arduino

Depending on the motor driver, the direction of the rotation can be switched by a control signal. Equipped with two control connectors, when one side is set to High, it will rotate normally while another side that is set to High will rotate in reverse. This allows forward, reverse and stop controls possible.

Connecting the Motor to Arduino

Now let’s try controlling the motor from Arduino. The following electronics will be used for this portion, so please make sure you have them prepared.

DC Motor

This is the motor body. These types of motors that use dry batteries are called「DC Motor」. For this article, we’ll be using「RE-280RA」. The RE-280RA battery can support electric voltage of up to 4.5V.

DC motor

Motor Driver

We’ll be using this to control the motor. Following signals from Arduino, you can control the supply of electricity to the motor and the rotational direction. We’ll be using「BA6956AN」made from ROHM. From the connector with cutouts (left side in the picture), they’re counted as Connector 1 and Connector 2.

motor driver

Condenser 0.1μF

A condenser is an electrical component that can store a small amount of electricity. When it is running on a motor, it will begin to make noise. This noise has potential negative effects on other operable electrical parts. So because of that, connect the condenser to both connectors to help reduce the noise.

condenser

Resistor10kΩ(1/4W)

In order to prevent electronic components from breaking due to sudden large electrical current flows, the current can be suppressed by using a resistor. This time, in order to specify the voltage being supplied to the motor, the Arduino 3.3V connector is connected to the motor driver. Normally, there are almost no current flows, but a large current may flow in some cases, so connect a 10kΩ resistor to prevent any large currents from flowing. A 10 kΩ resistor is printed with “Brown Black Orange Gold” along with a color code.

resistor

Battery

Battery Snap

Batteries are used as the power source for rotating the motor. Here, a 006P that can supply up to 9V voltage will be used. It also uses battery snaps to connect the batteries to the breadboard.

9v battery

battery snap

Electrical Clips Jumper Lines

For the motor, wiring for the connectors up to the breadboard is necessary. Usually, the conductor is soldered onto the connector. However, if you use the electrical clip jumper wire, you can just wire it by inserting the clip into the motor connector, eliminating the need for soldering.

electrical clip jumper wires

Once you prepare each of the components, connect like below.

prepare each of the components

Connect the motor to Connectors 2 and 4 of the motor driver by pinching the connector with the electrical clip. Keep in mind that noise may be generated during motor operation, which may affect other devices. Therefore, connecting capacitors to both connectors of the motor will reduce the amount of noise.

The motor can be powered from a separately prepared battery. Therefore, power can be supplied from the battery by connecting the battery to the fifth and third connectors of the motor driver.

In addition, the motor used this time has a power supply range of up to 4.5V. For this reason, the voltage may be too high with a 9V battery, so there is the possibility that the motor may be damaged. Therefore, specify the maximum voltage of the output going into the motor at Connector 1 of the motor driver. This time, we will be able to supply up to 3.3V to the motor. Connect the Arduino 3.3V power supply to Connector 1 and specify the maximum voltage. Motor rotation can be controlled with the seventh and ninth connectors of the motor driver. This means connecting to Connectors 5 and 6 of Arduino allows you to control the motor via Arduino’s output.

Controlling the Motor on a Program

Once connected, let’s actually try controlling the motor with a programming code. The rotation of the motor can be controlled by the output of Arduino Connectors 5 and 6. Rotation, stop and rotation direction can all be controlled by waning High or Low in these two connectors. In the case of BA6956AN, it can be controlled as follows.

For normal rotations, Connector 5’s output is set at High while the output for Connector 6 is set at Low. Writing the below programming code into Arduino should start the motors normal rotation.

At the tenth line, the output should be set at High, while at Connector 6 on the sixth line, output should be set at Low.

When you would like to make the motor rotate in the opposite direction, Connector 5’s output should be set at Low, while Connector 6’s output should be set at High.

The programming code should look like the following:

On the tenth line, Connector 5’s output should be set at Low while on the eleventh line, Connector 6 should be set at High. When you would like to stop the motor, both the output for Connectors 5 and 6 should set at Low.

The programming code should look like the following:

In addition, setting both outputs at High will cause it to turn on the breaker. Setting either of them at Low will cause it to stop in a short amount of time.

Changing the Rotation Speed of the Motor

Last time, we were able to change the brightness by using an LED output method called PWM. Even on a motor, the rotational speed can be changed by controlling the motor with PWM. By switching between High and Low in a short amount of time, the motor alternatively switches between rotation and stop, with the rotation speed actually being slower than normal. The longer the High time, the faster the rotation speed will be, and vice versa.

For the motor, output the control connector of the direction you would like to rotate on PWM and always keep the other connector at Low. For normal rotations, output Connector 5 on PWM and keep Connector 6 at Low. For inverse rotation, output Connector 6 on PWM, and keep Connector 5 at Low. The programming code for controlling the speed of the normal rotation is listed below.

For the programming code, set output Connector 5 on line 10 to half the ratio of PWM (biggest at 255) and keep Connector 6 on line 11 at Low. If you change the number on line 10, the speed will also change. However, the motor will not rotate if High is less than a certain percentage. If the motor doesn’t rotate with a small value, try specifying a higher value. You can gradually change the speed by gradually increasing or decreasing the value output from Connector 5. In the next program, the rotation speed will gradually increase from the stop state, and once it reaches the maximum, the speed will gradually decrease and stop.

For today, we went over different ways you can operate electronic components on Arduino such as LED or motors. Next time, we’ll be talking about how to look up the condition of switches on Arduino.

Device Plus Editorial Team
Device Plus Editorial Team
Device Plus is for everyone who loves electronics and mechatronics.

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • The Basics of Arduino: Reading Switch StatesThe Basics of Arduino: Reading Switch States
  • ESP-WROOM-02 Setup GuideESP-WROOM-02 Setup Guide
  • The Basics Of Arduino: Control LED Lighting with Digital OutputThe Basics Of Arduino: Control LED Lighting with Digital Output
  • From Electric Skateboards to Drones: 5 DIY Projects To Hone Your Electronics SkillsFrom Electric Skateboards to Drones: 5 DIY Projects To Hone Your Electronics Skills
  • Let’s Play with ESP-WROOM-32 on Arduino (Bluetooth-BLE Connection)Let’s Play with ESP-WROOM-32 on Arduino (Bluetooth-BLE Connection)
  • Using Arduino with Parts and Sensors – Stepper Motor Part 1Using Arduino with Parts and Sensors – Stepper Motor Part 1
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort