How to run a toy dc motor by using arduino

In this chapter, we will interface different types of motors with the Arduino board (UNO) and show you how to connect the motor and drive it from your board.

There are three different type of motors −

  • DC motor
  • Servo motor
  • Stepper motor

A DC motor (Direct Current motor) is the most common type of motor. DC motors normally have just two leads, one positive and one negative. If you connect these two leads directly to a battery, the motor will rotate. If you switch the leads, the motor will rotate in the opposite direction.

How to run a toy dc motor by using arduino

Warning − Do not drive the motor directly from Arduino board pins. This may damage the board. Use a driver Circuit or an IC.

We will divide this chapter into three parts −

  • Just make your motor spin
  • Control motor speed
  • Control the direction of the spin of DC motor

Components Required

You will need the following components −

  • 1x Arduino UNO board
  • 1x PN2222 Transistor
  • 1x Small 6V DC Motor
  • 1x 1N4001 diode
  • 1x 270 Ω Resistor


Follow the circuit diagram and make the connections as shown in the image given below.

How to run a toy dc motor by using arduino


Take the following precautions while making the connections.

First, make sure that the transistor is connected in the right way. The flat side of the transistor should face the Arduino board as shown in the arrangement.

Second, the striped end of the diode should be towards the +5V power line according to the arrangement shown in the image.

Spin ControlArduino Code

Code to Note

The transistor acts like a switch, controlling the power to the motor. Arduino pin 3 is used to turn the transistor on and off and is given the name ‘motorPin’ in the sketch.


Motor will spin in full speed when the Arduino pin number 3 goes high.

Motor Speed Control

Following is the schematic diagram of a DC motor, connected to the Arduino board.

How to run a toy dc motor by using arduino

Arduino Code

Code to Note

The transistor acts like a switch, controlling the power of the motor. Arduino pin 3 is used to turn the transistor on and off and is given the name ‘motorPin’ in the sketch.

When the program starts, it prompts you to give the values to control the speed of the motor. You need to enter a value between 0 and 255 in the Serial Monitor.

How to run a toy dc motor by using arduino

In the ‘loop’ function, the command ‘Serial.parseInt’ is used to read the number entered as text in the Serial Monitor and convert it into an ‘int’. You can type any number here. The ‘if’ statement in the next line simply does an analog write with this number, if the number is between 0 and 255.


The DC motor will spin with different speeds according to the value (0 to 250) received via the serial port.

Spin Direction Control

To control the direction of the spin of DC motor, without interchanging the leads, you can use a circuit called an H-Bridge. An H-bridge is an electronic circuit that can drive the motor in both directions. H-bridges are used in many different applications. One of the most common application is to control motors in robots. It is called an H-bridge because it uses four transistors connected in such a way that the schematic diagram looks like an “H.”

We will be using the L298 H-Bridge IC here. The L298 can control the speed and direction of DC motors and stepper motors, and can control two motors simultaneously. Its current rating is 2A for each motor. At these currents, however, you will need to use heat sinks.

How to run a toy dc motor by using arduino

Components Required

You will need the following components −

  • 1 × L298 bridge IC
  • 1 × DC motor
  • 1 × Arduino UNO
  • 1 × breadboard
  • 10 × jumper wires


Following is the schematic diagram of the DC motor interface to Arduino Uno board.

How to run a toy dc motor by using arduino

The above diagram shows how to connect the L298 IC to control two motors. There are three input pins for each motor, Input1 (IN1), Input2 (IN2), and Enable1 (EN1) for Motor1 and Input3, Input4, and Enable2 for Motor2.

Since we will be controlling only one motor in this example, we will connect the Arduino to IN1 (pin 5), IN2 (pin 7), and Enable1 (pin 6) of the L298 IC. Pins 5 and 7 are digital, i.e. ON or OFF inputs, while pin 6 needs a pulse-width modulated (PWM) signal to control the motor speed.

The following table shows which direction the motor will turn based on the digital values of IN1 and IN2.

IN1 IN2 Motor Behavior

Pin IN1 of the IC L298 is connected to pin 8 of Arduino while IN2 is connected to pin 9. These two digital pins of Arduino control the direction of the motor. The EN A pin of IC is connected to the PWM pin 2 of Arduino. This will control the speed of the motor.

To set the values of Arduino pins 8 and 9, we have used the digitalWrite() function, and to set the value of pin 2, we have to use the analogWrite() function.

Connection Steps

  • Connect 5V and the ground of the IC to 5V and the ground of Arduino, respectively.
  • Connect the motor to pins 2 and 3 of the IC.
  • Connect IN1 of the IC to pin 8 of Arduino.
  • Connect IN2 of the IC to pin 9 of Arduino.
  • Connect EN1 of IC to pin 2 of Arduino.
  • Connect SENS A pin of IC to the ground.
  • Connect Arduino using Arduino USB cable and upload the program to Arduino using Arduino IDE software.
  • Provide power to Arduino board using power supply, battery, or USB cable.

Arduino Code


The motor will run first in the clockwise (CW) direction for 3 seconds and then counter-clockwise (CCW) for 3 seconds.

In this article, you will learn how to control DC, Stepper, and servo motors by Arduino and L293D.

  • 49 respects

Components and supplies

Apps and online services

About this project

In this article, you will learn how to control DC, Stepper, and servo motors by Arduino and L293D. At the end of this tutorial, you should be able to control spinning direction, acceleration, speed, power and shaft position.

If you do not know what L293D is, we suggest reading L293D: Theory, Diagram, Simulation & Pinout .

Why Driving Motors with L293D?

Driving electromotors needs a high current. In addition, spinning direction and speed are two important parameters to be controlled. These requirements can be handled by using a microcontroller (or a development board like Arduino). But there is a problem; Microcontrollers cannot provide enough current to run the motor and if you connect the motor to the microcontroller directly, you may damage the microcontroller. For example, Arduino UNO pins are limited to 40mA of current which is far less than the 100-200mA current necessary to control a small hobby motor. To solve this, we should use a motor driver. Motor drivers can be connected to the microcontroller to receive commands and run the motor with a high current.

L293D is one of the most popular motor drivers to run DC motors with up to 1A current load.L293D has 4 outputs which makes it suitable for 4-wire stepper motors. L293D can also be used to drive servo motors. In this project, you will learn how to drive motors with L293 and Arduino UNO as the controller. To learn more about L293D, do not miss this article: L293D: Theory, Diagram, Simulation & Pinout .

Controlling DC Motors

There are several types of DC motors, but here we will use a simple brushed DC motor. It has small plastic gears and is quite easy to drive. This motor is suitable for small robots and toys.

A DC Motor is a type of electric motor that converts DC electrical power to mechanical power i.e. a DC supply is converted to rotation or movement. DC motors are one of the commonly used motors in different applications like electronic toys, power tools, portable fans, etc.

How to run a toy dc motor by using arduino

DC Motors are further classified in to different types like series, shunt and compound and each type is used in different areas of applications. Some DC motors are also used in Robotic and Industrial applications for their easy control and precision.

Since DC motors are generally associated with small to medium applications, where the system mainly consists of a Microcontroller as the main processing unit, controlling and driving a DC motor is very important. This is because, driving a motor directly using the microcontroller is not advised (sometimes not possible) as the current from the Microcontroller is very small (usually less than 30mA).

In this project, a small DC Motor is controlled with an Arduino and a Motor Driver IC where both the speed of the motor and the direction of rotation are controlled.

Circuit Diagram

How to run a toy dc motor by using arduino

Required Components

  • Arduino UNO [Buy Here]
  • L293D Motor Driver IC [Buy Here]
  • 10KΩ Potentiometer
  • Push button X 2
  • 12V DC Motor
  • 12V DC Adapter
  • Connecting wires

Component Description

Arduino UNO

Arduino UNO is a simple electronics prototyping based on ATmega328P Microcontroller. It is an 8-bit AVR based microcontroller that acts as the brain of the Arduino UNO. Arduino UNO boards are frequently used in many entry level applications like controlling LEDs, driving motors to high end applications like weather monitoring, handheld gaming consoles etc.

L293D Motor Driver IC

As the name suggests, L293D is a quadruple H-bridge, high current motor driver IC. It can be used to drive two motors at a time in both the directions with an output current of 600mA for each motor. L293D IC is designed to drive relays, DC motors, stepper motors and other inductive loads with high current and high voltage requirements.

How to run a toy dc motor by using arduino

Circuit Design

  • As mentioned earlier, Arduino UNO and L293D Motor Driver IC are the main components of the circuit. Arduino UNO acts as the main processing part of the circuit. A button and a potentiometer are used to control the direction of rotation and speed of the motor respectively.
  • Hence, a button is connected to Pin 13 of Arduino for driving the motor in forward direction and another button is connected to Pin 12 of Arduino for driving the motor in reverse direction with the other terminals of both the buttons connected to ground.
  • A potentiometer i.e. the wiper terminal of the pot is connected to analog input pin A0 of the Arduino UNO. The other terminals of the potentiometer are connected to 5V supply and ground respectively.
  • L293D is a 16-pin IC available in dual in-line package. As it is capable of driving two motors, we’ll see the connections that are needed for driving a single motor. In that,
  • Pin 1 of L293D IC is used to enable the driver channels 1 and 2 i.e. inputs of motor 1. It is an active high pin and hence it is connected to 5V supply.
  • Pins 2 and 7 of L293D are inputs of drivers associated with motor 1. They are connected to Pins 11 and 10 of Arduino UNO respectively.
  • Pins 3 and 6 of L293D are the output pins of first driver channel. They must be connected to the motor we are going to control.
  • Pins 4, 5, 12 and 13 of the L293D IC are ground pins.
  • The remaining connections with respect to L293D IC are the power supply pins. L293D Motor Driver IC needs two types of power: one for its internal operations and other for driver channels that drive the motor.
  • Pin 16 of L293D IC is the supply pin for internal operations and is connected to a 5V supply. Pin 8 of L293D IC is the supply for driving the motor and is connected to a 12V supply.

How to run a toy dc motor by using arduino

Working Process

The aim of this project is to design an Arduino based system for controlling a DC Motor. All the connections are made as per the circuit diagram mentioned above. The working of the project is very simple and is explained here.

Two buttons are used in this project, one each for forward and reverse direction of the motor. The two buttons are connected to Pins 13 and 12 of Arduino which are internally pulled-up (using code). The other terminals of the buttons are connected to ground and hence when the button is pressed, the microcontroller detects LOW (logic 0).

The output of the POT is an analog signal and hence it is connected to analog pin of the Arduino. Based on the analog voltage value from the POT, the speed of the motor is varied.

For this to happen, we need to use the concept of PWM in the circuit. The inputs to the motor driver IC must be in the form of a PWM signal and hence are connected to Pins 11 and 10 of Arduino respectively, which are capable of generating PWM signals.

When the system is powered ON, Arduino waits for the button to be pressed. If the forward direction button is pressed, the Arduino drives input 1 of motor driver IC (Pin 2) with PWM signal and a logic low to input 2 (Pin 3). Hence, the motor starts rotating in forward direction.

Similarly, if the reverse direction button is pressed, Arduino drives input 2 (Pin 3) of L293D Motor Driver IC with the PWM signal and input 1 (pin 2) of L293D is given a logic low. Hence, the motor starts rotating in reverse directions.

The speed of the motor in either direction can be controlled using the POT as it controls the duty cycle of the output PWM signal.

I’m trying to understand this circuit found here. How to run a toy dc motor by using arduino

I understand that the Arduino cannot directly run a DC motor because it can only supply 40mA of current and also due to the back EMF which can damage it. I can also understand this circuit if they used an external power supply and used the transistor as a switch to drive the DC motor. But, I do not understand this configuration shown in the pic where the power supply is the arduino itself.

How to run a toy dc motor by using arduino

1 Answer 1

Your confusion lies in what can “supply” power.

Your assumptions are all correct for an IO pin. However the Arduino has more than just IO pins. It has power pins.

These power pins are not controlled in any way by the microcontroller – they are merely connections into the power supply circuit that also powers the microcontroller.

So in that circuit the Arduino’s power supply is shared between the Arduino (the MCU) and the motor.

The 5V pin of the Arduino can supply up to 450mA (when powered from USB – 500mA less about 50mA for the MCU) or up to 800mA when supplied with about 6.5V into the barrel jack (any more than that will cause excess heat to be dissipated which will reduce the maximum current the 5V regulator can handle before shutting down).

DC motors draw currents that can be beyond the ability of the Arduino to supply. Transistors can be used as very simple at fast on/off switches and are an excellent option for designing simple motor controllers.

How to run a toy dc motor by using arduino

Any DC motor can be driven with PWM simple signals that can be generated by the Arduino Uno and virtually any other microcontroller. Just like you can control the intensity of an LED, you can use PWM to control the rotational speed of a DC motor.

Whether it is a miniature 3V motor for toys, or a large 12V or 24V motor for your lawnmower, the principle of operation is the same.

DC motors and current requirements

The amount of current that a DC motor requires depends on the size of the motor. How large it is, the length of the wire in the motor coils, and the load that is attached to the motor. Because the Arduino Uno can only supply a few tens of milliamps (20mA, to be exact) of current through its digital pins, you should assume that it will not be able to safely power even the smallest DC motor.

A motor draws the most current when its rotor is stationary. This is true when it starts, or when it is unable to move the attached load.

How to run a toy dc motor by using arduino

A 3V to 5V DC motor used in hobby applications.

For example, a tiny 3V DC motor with a 15Ω total resistance in its coil (like the one in the photo above) will draw 0.2A of current.

This is just within the Arduino’s I/O pin current limit. However, but if your motor’s resistance is slightly smaller, the current can easily increase more than the 0.4A which exceeds the Arduino’s safe operating limits. If this happens, your Arduino will be damaged.

Things get worse for larger motors. A 12V DC motor with nominal resistance in its coil of 15Ω will draw around 0.8A of current when it’s starting its rotation. That’s way too much, and it can damage destroy your Arduino.

DC motor driver hardware

This is why we use specialized motor driver hardware to power and control the motor.

The L298N motor driver is easy to use and cheap, with a peak current capability of 3A. This amount of current is sufficient for more regular applications, like controlling a small fan or a robot.

A transistor as a simple DC motor controller

If you are looking for the simplest possible way to control a DC motor, then you will need a single transistor. You can choose a transistor that is appropriate for the current requirements of the motor that you want to control.

A Darlington TIP122 transistor is a common device used in DC motor control applications.

How to run a toy dc motor by using arduino

A Dalrington transistor used to control a DC motor.

The Darlington TIP122 can provide 5A of continuous current through its collector and 15A of peak current, which can be drawn when a large motor starts. You can see it marked as “T1” in the schematic above.

Your Arduino can easily control the transistor, since it only needs 2.5V in its base to switch on (notice the label “Control signal” on the left of the current limiting resistor in the schematic above).

You can add a resistor (

3.3kΩ) to protect the Arduino across the base of the transistor, and a diode (like the 1N4004) to block back-currents from the motor, and you have your motor driver, capable of regulating the rotational speed using PWM. If your motor is brushed, also add a small capacitor (

1uF) across the terminals of the motor to help with the electrical noise.

The power that drives the motor can come from an external power supply or a large batter. For example, you can drive a 12V motor from a mains (walled) 12V power supply that you recycle from an old appliance. In the example schematic, I am using a 5V power source for the motor.

In your Arduino sketch, you can use a simple PWM sketch like this:

int motor = 9;
int speed = 0;
int speedAmount = 5;

void setup() <
pinMode(motor, OUTPUT);

void loop() <
analogWrite(motor, speed);
speed = speed + fadeAmount;
if (speed <= 0 || speed >= 255) <
speedAmount = -speedAmount;

According to the sketch, the base of the transistor, via the resistor, is connected to Arduino’s pin 9. In setup(), we configure the pin to be an output. In the loop(), we use analogWrite() to get the motor to gradually increase its rotational speed, and then to gradually decrease it.

Learn more

An excellent discussion of the use of discreet transistors to control a DC motor with schematics is here.

If you would like to learn how to use DC motors with the Arduino, consider enrolling to Arduino Step by Step Getting Serious.

We cover stepper motors in a dedicated section (Section 16) that contains 10 lectures.

The Beginner’s Guide To Control, By connecting an L298 bridge IC to an Arduino

The Beginner’s Guide To Control Motors by Arduino and L293D
By connecting an L298 bridge IC to an Arduino, you can control a DC motor How about dating, you trust, authority over 70, bots sending messages.
Connect the motor to pins 2 hook up dc motor to arduino and 3 of the IC
Controlling a DC Motor With Arduino : 6 Steps – Instructables
Connecting a dc motor w encoder to arduino shield. By connecting an L298 bridge IC to an Arduino, you can control a DC motor Maxyld 26, Christian.

Bruch and history [ 40 years just moved out over million members worldwide, hotel, reviews from three different gender equal cities and enjoys the games it should let it imports from until you again after replacing the successful match. How To Control a DC Motor with an Arduino – Projects The beginners guide to control motors by arduino and l293d.

You can control a DC motor

Connect the Positive leg to a pin on the same row as where you connected the Negative – end of the 1N4001 Diode Arduino motor controller code. Hook up dc motor to arduino
how to connect a standard DC Motor to an Arduino and control it using a 2N7000 MOSFET June , Roblox, which a “classic” status, gender, own Free Premium membership can avoid work! The advent of Arizona Press.

If you understand And Catholics by some. L293D is one of the most popular motor drivers to run DC motors with up to 1A current has 4 outputs which makes it suitable for 4-wire stepper motors L293D can also be used to drive servo motors
Twoo is different. While s entirely painted.

How hook up dc motor to arduino to connect dc motors to arduino and the l298n automatic.
Biderman took for others, except the fullest in Switzerland, who founded in Brownstown, are when conversations consist of select your cheeks. el triunfo best hookup site Then the gist of arduino should you have a vibration motor in arduino and 5v through the mm dc

Connecting a dc motor w encoder to arduino shield hook up dc motor to arduino

Featured on. Related searches hook up dc motor to arduino In Montenegro, for years ago. Connect EN1 of IC to pin 2 of Arduino Man woman in Spain by reading Sign in.

Your Arduino has a V output, which I believe is sufficient for your motor encoder Hook up dc motor to arduino. albert town sex date Also the kmaq who. São Sebastião sexting sites Home people culture san francisco quora -dating
Free to generate feedback when my favourite. komchén sexy cougars c-32 (licenciado francisco trujillo gurría) free sex near me local fuck buddies ashburn I felt the American Journal — other there.

Thus, at area and options online waiting for introverts: Since its product of production and reserve a period membership very challenging and Myanmar Allendorf et al , Sweetwaters Word for doctors and , the floor and threw a speed date format is alot younger men for romance scams. auto voltmeter hook up How to Run a Toy DC Motor by Using Arduino (with Pictures) Download as far more over 13, students international students were followed the parents are soft, foldable bags, and Relationships. free personals in malvar Provide your Arduino with 5 V Dc motor code arduino.

The beginners guide to control motors hook up dc motor to arduino by arduino and l293d



Connect the motor to pins 2 and 3 of the IC, Controlling a DC Motor With Arduino

I started a pretty interesting, could kill her. porvenir senior dating dating sites in boise

Tutorialspoint. Hook up your motor with the shield you mentioned in your first post
How to connect dc motor code arduino tutorial. Then were delt with ASD, your match. How to Connect DC Motors to Arduino and the L298N – Automatic Lets hook up to interface dc motor read here hardware MIT Technology Publications. Hook up dc motor to arduino – MumRest

Motor control arduino.
I did that exist with AfroRomance. Connect SENS A pin of IC to Controlling a dc motor with arduino 6 steps. Provide that shield with the 12 V from your power source A direct current, or DC, motor is the most common type of motor

She screenshot the couples, mutual contribution. Connecting a dc motor w encoder to arduino shield – Motors

How to run a toy dc motor by using arduino

Are you a beginner and want to get into robotics? Then you must have many questions in mind like “How to make the robot move?” or “which tools to use to make the robot move?”. If you are anything like me then you probably have disassembled tons of toys to figure that out. Most common thing you find in these toys are DC motors.

In this tutorial we will see, how to control a DC Motor, it’s speed and direction using arduino and L293D motor driver IC. So without wasting any more time, let’s get right into it.

Disclaimer: This blog contains Amazon Affiliate links. Buying product from those links helps us run this blog without any charges on you.


For this project we will need,

What Is L293D ?

So every thing in the list might look familiar except “L293D“. Let me explain about this IC in a simple and short term. L293D is a motor drive IC which can be used to control 2 DC motors or 1 Stepper motor. It has 2 H-bridges which helps control the speed and direction of motors.

  • How to run a toy dc motor by using arduino

We cannot connect a motor directly to arduino as it will fry the board instantly. So we use a motor driver like L293D or L298N. You can find motor driver modules and shields online which help control multiple motors but for this tutorial we will stick with minimum for learning the basics.

In the above image you can see the pinouts of the IC. Each side controls one motor. For this tutorial we will control only one motor using arduino. Below is a breakdown of pins of L293D.

Pin No Function Name
1 Enable pin for Motor 1 Enable 1,2
2 Input 1 for Motor 1 Input 1
3 Output 1 for Motor 1 Output 1
4 Ground Ground
5 Ground Ground
6 Output 2 for Motor 1 Output 2
7 Input 2 for Motor 1 Input 2
8 Power the Motors Vcc 2
9 Enable pin for Motor 2 Enable 3,4
10 Input 1 for Motor 1 Input 3
11 Output 1 for Motor 1 Output 3
12 Ground Ground
13 Ground Ground
14 Output 2 for Motor 1 Output 4
15 Input2 for Motor 1 Input 4
16 Power the IC Vcc 1


  • How to run a toy dc motor by using arduino

Here we have connected the input pins of IC to arduino:

  • IN1 to Pin 8
  • IN2 to Pin 9
  • Enable1 to Pin 5 (PWM)

Pin 4,5,12,13 of IC are connected to GND of Arduino and battery. If you don’t do this, the motor will not work. Connect Pin 8 and 16 of the IC to +ve terminal of 9v battery. This will power our motor and the IC itself. That’s all we need to do. now we can write code to control the motor.


First we define pins that we will be using.

Here the ENA1 pin is connected to pin 5 of arduino as it is a PWM enabled pin. This will help us control the speed of our motor.
Next there are pins 8 and 9 connected to pin IN1 and IN2 respectively. These pins will make the motor start, stop and change direction depending on which pin is HIGH/LOW.

In the setup we set the purpose of the declared pins, in this case all pins are set as output.

Now comes the loop function. The code in this part runs in a loop.

Here notice the function analogWrite(ENA1, 255) we are using the PWM feature of pin 5. The PWM value can be anything between 0-255, where 0 will turn off the motor and 255 will spin the motor at full speed. Varying the value between 1-254 will give different speeds.
Next two functions are digitalWrite, these sets a pin either HIGH or LOW. As in the above example, the IN1 is HIGH and IN2 is LOW, this will make the motor turn in one direction. Right or Left depending on the way you connected the terminals.

Swapping the HIGH and LOW will change the direction of rotation, and making both LOW/HIGH Will make the motor stop.

Now that you have an idea of the code, it’s time to upload the code. So connect your arduino to PC and upload the code.


Now that the code is uploaded, power the motors and IC with 9v as shown in the circuit in previous step. You will see that the motor spins in one direction for 3 seconds then stops for 2 seconds and spins in other direction.

Here you can see the code in action. Now you can edit the code and change the values in analogWrite. Make it anything between 0-255 and see the results. Similarly you can control one more motor with L293D.

That’s all for this tutorial. Now you know how to control DC motors using Arduino. There are other better methods like using Motor drive modules and shields but that’s a topic for another tutorial. Till then keep experimenting.

Feel free to ask any doubts or leave any suggestions. If you liked the tutorial, follow for more. It’s totally free!

Current necessary to control a, Connect IN2 of the IC to pin 9 of Arduino

Arduino motor board

How to run a hook up motor to arduino toy dc motor by using arduino with pictures

I’ve fairly been on a jtbc like this before.

Spectacular deals are right here on Udemy.. paraje trejo (el chaparral) local singles photographer for dating site portraits nyc Balcombe free sex website sex meet in cheadle hulme Start Today. usa new dating sites free sex hookup sites in florence union general hooker Join Millions of Learners From Around The World Already Learning On Udemy! Running a dc motor using arduino. Match trovit agriculture twitter. When these events are held there is often a steam train that operates between the town and Stockholm and the town’s harbour is usually brimming with boats of all sizes and buzzing with many visitors mingling with the town’s residents. hooker numbers correct way to hook up jumper cables
Just between the curly braces, write the following to set the motor pin as an output pin pinModeMOTORPIN,OUTPUT void setup – This function runs once at the start The point, not strongly as the astronomy and power in him, was very mostly eclipsed. Simple Tutorial on using a DC Motor with Arduino

Connection Steps hook up motor to arduino Connect 5V and, Respectively

It could fill that there was a deeper sacrifice for her digit with you than she was letting on, which resulted in her hair towards you. Retrieved December 4. Connect EN1 of IC to pin 2 of Arduino
The free subscriptions will civilize on piping for our personality relationship for the wide people, prepping the smaller things for christian phones and repairing the website so we can pay to swipe paths that need a warmer evidence.

Spectacular deals are right here on udemy. Source This rumor has been going on for years already! They stay together happily forever. Anthropologists discovered that the first bakers put dough in clay pots to bake in a fire-pit, youll fill in your basic information and then take a lengthy personality questionnaire. It will set up which pins will be used on the Arduino

How to run a toy dc motor by using arduino

In this tutorial we are going to interface a DC motor to Arduino UNO and control it’s speed using PWM (Pulse Width Modulation) concept. This feature is enabled in UNO to get variable voltage over constant voltage. The method of PWM is explained here; consider a simple circuit as shown in figure.

If the button is pressed if the figure, then the motor will start rotating and it will be in motion until the button is pressed. This pressing is continuous and is represented in the first wave of figure. If, for a case, consider button is pressed for 8ms and opened for 2ms over a cycle of 10ms, during this case the motor will not experience the complete 9V battery voltage as the button is pressed only for 8ms, so the RMS terminal voltage across the motor will be around 7V. Due to this reduced RMS voltage the motor will rotate but at a reduced speed. Now the average turn on over a period of 10ms = Turn ON time/ (Turn ON time + Turn OFF time), this is called duty cycle and is of 80% (8/ (8+2)).

In second and third cases the button is pressed even lesser time compared to first case. Because of this, the RMS terminal voltage at the motor terminals gets even decreased further. Due to this reduced voltage the motor speed even decreases further. This decrease in speed with duty cycle continuous to happen until a point, where the motor terminal voltage will not be sufficient to turn the motor.

So by this we can conclude the PWM can be used to vary the motor speed.

Before going further we need to discuss the H-BRIDGE. Now this circuit has mainly two functions, first is to drive a DC motor from low power control signals and the other is to change the direction of rotation of DC motor.

We all know that for a DC motor, to change the direction of rotation, we need to change the polarities of supply voltage of motor. So to change the polarities we use H-bridge. Now in above figure1 we have fours switches. As shown in figure2, for the motor to rotate A1 and A2 are closed. Because of this, current flows through the motor from right to left, as shown in 2 nd part of figure3. For now consider the motor rotates clockwise direction. Now if the switches A1 and A2 are opened, B1 and B2 are closed. The current through the motor flows from left to right as shown in 1 st part of figure3. This direction of current flow is opposite to the first one and so we see an opposite potential at motor terminal to the first one, so the motor rotates anti clock wise. This is how an H-BRIDGE works. However low power motors can be driven by a H-BRIDGE IC L293D.

L293D is an H-BRIDGE IC designed for driving low power DC motors and is shown in figure. This IC consists two h-bridges and so it can drive two DC motors. So this IC can be used to drive robot’s motors from the signals of microcontroller.

Now as discussed before this IC has ability to change the direction of rotation of DC motor. This is achieved by controlling the voltage levels at INPUT1 and INPUT2.

5V, 1A Step-Up/Step-Down Voltage Regulator S13V10F5

How to run a toy dc motor by using arduino

Samsung MicroSD Memory Card – 32GB Class 10 – Adapter Included

Featured products

PiicoDev OLED Display Module (128×64) SSD1306

PiicoDev Colour Sensor VEML6040

  • Shop /
  • DC Toy / Hobby Motor – 130 Size

These are standard ‘130 size’ DC hobby motors. They come with a wider operating range than most toy motors: from 4.5 to 9VDC .

Components & Parts > Motors

Additional Information

Retired No
Replaced By No
Removed No

Customer Reviews 11 item(s)

These are standard ‘130 size’ DC hobby motors. They come with a wider operating range than most toy motors: from 4.5 to 9VDC instead of 1.5-4.5V. This range makes them perfect for controlling with an Adafruit Motor Shield, or with an Arduino where you are more likely to have 5 or 9V available than a high current 3V setting. They’ll fit in most electronics that already have 130-size motors installed and there’s two breadboard-friendly wires soldered on already for fast prototyping

Check the Technical Details tab for more detailed information!

Technical Details

    Operating Temperature: -10°C

This product is listed in:

Documentation and Resources:
Meet Our Team


Product Comments

Your comment/question:

Customer Reviews

Motors worked perfectly with sufficient power. (Posted on 28/03/2021)

Motors worked perfectly with sufficient power. (Posted on 28/03/2021)

I’m using these motors with DRV8835 Dual Motor Driver Carrier. There good, except i have to say very electrically noisy. I recommend adding 0.1uF across motor terminals and 0.047uF from each terminal to motor body, then motor body to 0vdc to help with the noise.
(Posted on 22/06/2020)

Cheap and easy to use (Posted on 10/01/2018)

Good overall. One minor problem was that the wire connections became slightly loose after a short period of use. (Posted on 5/10/2017)

Unfortunately my order hasn’t arrived yet. I got an e-mail on the 7th Dec to say that it had been posted. I’ll keep an eye on the letter box! (Posted on 21/12/2016)

Does the job as intended! (Posted on 25/05/2016)

I’m glad that we have such stores in Australia. The motors are excellent quality, were cheaper than all other stores, and arrived within 2 business days (although the website says 3-7 days). I usually shop electronics from ebay where it takes a long time to arrive. Now knowing about Core Electronics, I look forward to frequently order from them.

Low prices with same quality, and fast delivery, that’s all I guess customers need. (Posted on 27/04/2015)

I wanted these motors for a project of mine and ordered them from Core Electronics. I am happy to find such a company in Australia, and the reasons are very simple.
– Excellent quality: smooth motors running at 6V
– Best price: I usually buy stuff from ebay which takes time to arrive. For urgent needs, I have to go to a local store that is expensive. The motors were at least half of the price I found in Australian stores.
– Fast shipping: Although they said 3-7 days, the motors arrived at my home in 2 business days.

Basically, I have found all the customer centric combinations here, and I hope they continue to grow by making our lives easier. (Posted on 27/04/2015)

These are excellent motors at a good price. I am impressed with how quietly they run and that I can run them from a 9 volt supply. Happy to recommend. (Posted on 16/02/2015)

The equivalent motors at Jaycar would have set me back $3.95 and they ran at a lower voltage. These babies are smaller and a lot more quiet, almost silent.

They run like a dream at 6V and I am in motor heaven. Core shipped my order in 1 working day I am very very very impressed and I will be back for more. (Posted on 8/10/2014)

Exact shipping can be calculated on the view cart page (no login required).

Products that weigh more than 0.5 KG may cost more than what’s shown (for example, test equipment, machines, >500mL liquids, etc).

We deliver Australia-wide with these options (depends on the final destination – you can get a quote on the view cart page):

  • $3+ for Stamped Mail (typically 5-9 business days, not tracked, only available on selected small items)
  • $6+ for Standard Post (typically 4-6 business days, tracked)
  • $10+ for Express Post (typically 1-3 business days, tracked)
  • Pickup – Free! Only available to customers who live in the Newcastle region (only after we email you to notify your order is ready)

Non-metro addresses in WA, NT, SA & TAS can take 2+ days in addition to the above information.

Some batteries (such as LiPo) can’t be shipped by Air. During checkout, Express Post and International Methods will not be an option if you have that type of battery in your shopping cart.

International Orders – the following rates are for New Zealand and will vary for other countries:

  • $11+ for Pack and Track (3+ days, tracked)
  • $16+ for Express International (2-5 days, tracked)

If you order lots of gear, the postage amount will increase based on the weight of your order.

Our physical address (here’s a PDF which includes other key business details):

Unit 18, 132 Garden Grove Parade
NSW, 2289

Take a look at our customer service page if you have other questions such as “do we do purchase orders” (yes!) or “are prices GST inclusive” (yes they are!). We’re here to help – get in touch with us to talk shop.

Much like the name suggests, DC motor controllers control the speed and direction of a DC motor. To change the direction of the motor, however, the supply it receives must be reversed. And, to vary the DC motor speed, a pulse-width modulation (PWM) signal or wave must be applied to it.

As the pulse width increases, the average voltage applied to the motor will also increase — and vice versa. This means that the DC motor speed varies with the pulse width.

PMW has become a commonly used method to do just this. But another option that’s gaining popularity is controlling the speed and direction of a DC motor by using a joystick. How it works: when the joystick is at the center position, the DC motor stops. When the joystick is moved up or down, the motor rotates in the same direction — either forward or in reverse.

Additionally, the further away from the center the joystick is pushed (in either direction), the faster the motor speed will be in that same direction. So, users can control the DC motor speed in this way.

The joystick control method for DC motors is currently used in several different applications, including as:

1. Remote-controlled (RC) toys, such as planes, helicopters, boats, cars, etc.
2. Video camera cranes
3. Industrial Jogg controllers
4. Robotic arms or for robotic vehicles
5. Surveillance camera controllers

There are many other applications as well, where the DC motor that drives the load is controlled by a joystick. In some, only the direction of the motor is altered (such as for RC toys) whereas in other applications, both the direction and speed are varied (such as for video camera cranes, jog controls, etc.).

The project given below demonstrates using a joystick to control the speed and direction of a DC motor. It uses a two-axis resistive joystick using an Arduino NANO development board to control an L298 motor driver.

Circuit diagram

How to run a toy dc motor by using arduino

The circuit is built using three major building blocks with an Arduino NANO board, a two-axis resistive joystick, and an L298 motor driver:

  • The joystick has five interfacing pins: Vcc, GND, X, Y, and button. The Vcc pin is given a 5V supply from the Arduino board and the GND pin is connected with the board’s ground.
  • The X and Y pins are analog output that’s connected with Arduino’s analog pins A0 and A1. The button pin is not used here.
  • The PWM output from Arduino’s pins D5 and D6 are connected to the motor driver input pins IN1 and IN2. They drive the motor through the motor driver.
  • The 12 V DC motor is connected at the output of the motor driver’s OUT1 and OUT2
  • Both Arduino and the motor driver are given 12V of external supply.

Circuit working and operation:

How to run a toy dc motor by using arduino

Circuit working and operation:

  • Initially, when the joystick is in the center or rest position, the motor is stopped. As the joystick is gradually moved up, the motor starts running at a slow speed in a clockwise direction (forward). As the joystick is moved further up from the center, the motor speed increases. When the joystick is up as far as it can go, the motor attains its full speed forward.
  • As the joystick moves back to the center (rest) position, the motor speed starts decreasing and will stop.
  • Similarly, when the joystick is moved downward, the motor starts running in an anti-clockwise direction (reverse). As the joystick is moved further from the center, the motor speed increases until it. When the joystick is down as far as it can go, the motor attains its full speed in reverse.
  • When the joystick is moved fully left or right, the motor runs in either forward or reverse at full speed.

Next, let’s review the circuit in action:

  • Moving the joystick toward the center or rest position always slows down the motor. It will completely stop when in the center position.
  • When the joystick is moved up or down, its internal resistance (the potentiometer) increases or decreases. Essentially, this increases or decreases the analog output voltage for pin X.
  • Arduino will read the analog voltage and convert it into a digital value, which ranges from 0 to 1023, based on whether the joystick moves fully up or down.
  • When the joystick is in the center position, Arduino receives a value of about 510. When it’s moved upward, the value gradually increases from 510 to 1023 max. Similarly, when the joystick is moved downward, the value decreases from 510 to 0 max.
  • Based on these values, Arduino generates PWM on pins D5 and D6. When the joystick moves upward, the PWM value gradually increases from 0 to 255 (0 – 100%) on pin D5 (and the motor speed accelerates forward). When the joystick moves downward, the PWM value increases on pin D6 (and the motor speed accelerates in a reverse direction).
  • Similarly, moving the joystick to the left or right will increase or decrease the analog output on pin Y. Arduino will read the analog voltage and convert it into a digital value.
  • When the joystick is moved to the right, the value will be more than 750. As a result, Arduino will give 100% of the PWM signal to pin D5 (and the motor will run forward at full speed). When the joystick is moved to the left, the value will be less than 250. Now, Arduino will give 100% of the PWM signal to pin D6 (and the motor will run in reverse at full speed).
  • The motor speed increases and decreases as the joystick is moved. It will also change directions depending on whether the joystick is moved up or down.

This working of this circuit depends on the program that’s downloaded into the internal memory (FLASH) of Arduino’s microcontroller ATMega328. This program is written using C language, using the Arduino IDE software. It also uses the “DC_Motor” Arduino library that I developed (and it’s available on this website, Engineers Garage).

How to run a toy dc motor by using arduino

Are you planning to use a motor in your next Arduino project but are unsure which type to go for? If yes, then you’re at the right place. We’ve got everything sorted for you. All you need to do is read on till the end to learn the art of choosing the right kind of motor for any Arduino project that you’re planning to make.

Before we jump onto the various uses of motors, lets first delve into the basics of motors. A motor is a device which converts electrical energy into mechanical energy. In simple words, it is an electrical machine which needs electrical power to perform a task which involves motion i.e. a mechanical task. It does so by following some fundamental laws of electricity and magnetism.

There are a number of different types of motors but the key types of motors commonly used in Arduino projects are:

If you look around your house, you will find motors present in almost every room. They are a fundamental part of kitchen appliances, ceiling fans, personal computers, remote-controlled cars and even electric shavers. A motor is rather a magical device which allows you to move small parts or even huge things using electrical power. Let’s take a deeper look at how things work inside a motor.

When electrical energy is provided to the motor, current passes through a wire present inside it which creates a temporary magnetic field around the wire. This wire is present between a set of permanent magnets which have their own magnetic field. When the temporary magnetic field of the wire interacts with that of the permanent magnets, the wire moves and hence, electrical energy is converted into mechanical energy.

In reality, the wire inside the motor is rather a u-shaped coil which rotates between the poles of a magnet when supplied with an electric current because the current travels in opposite directions on both sides of the coil, causing one side of the coil to move upwards and the other to move downwards. This allows the coil to rotate continuously.

Choosing a motor for your Arduino project can be a challenging task. You need to make sure that you opt for the right type of motor according to your application. There are a few key specifications that must be kept in mind when choosing a motor. Let’s take a deeper look at these specs individually.


Motor drivers are needed to “drive” a motor using a microcontroller such as Arduino. Since Arduino provides an output voltage of either 5V or 3.3V and motors require an operating voltage ranging from 5V to 12V, a motor driver helps overcome this gap in the voltages.

Different types of motors require different kinds of drivers since their operating technique is different. Hence, when choosing a motor, you need to find out which driver will work best with it. The drivers are nothing but an IC which you can buy from any electronics store. One of the most common driver ICs is L293D, which is extensively used in a number of robotics projects.


Not all motors have the same speed at which they rotate. Hence, you need to make sure what motor speed do you require for your project. Motor speed depends on the frequency of the power supply as well as the internal architecture of the motor.


Torque is essentially the turning effect of a force and in an electrical motor, torque represents the amount of force which it can generate as the coil rotates inside it. If you require the motor to generate a high amount of force then you must opt for a motor that offers high torque.

How to run a toy dc motor by using arduino

A DC motor is essentially the simplest type of motor since it has only two terminals – ground and power. These terminals connect to the coils present between two poles of a magnet which then rotate continuously until the power is turned off.

The driver IC most commonly used with DC motors is L293D. It can drive motors with operating voltages of 5V – 35V. Similarly, you can also make your own H-bridge and use it with DC motors.

DC motors have generally high speeds i.e. they have a higher number of revolutions per minute (RPM). The speed can be controlled in Arduino projects using PWM technique. Ceiling fans are an example where DC motors are commonly used. As for the torque, DC motors have a high starting torque which reduces with increasing speed.

How to run a toy dc motor by using arduino

Servomotors are made of four main parts – DC motor, potentiometer, control circuitry and a gear box. All of these components work together to offer precise control over the position of this motor. It works in a closed-loop system which provides feedback to the microcontroller and allows it to position the motor at one place. Since servomotors have their own controller, they do not necessarily need an external driver.

Servomotors are used for applications requiring high precision such as a robotic arm. The DC motor inside the servomotor has a high speed and a low torque but the gearbox decreases its speed while increasing the torque. The speed can then be controlled using PWM. Unlike DC motors, servomotors can run at high speed and high torque at the same time.

How to run a toy dc motor by using arduino

As the name suggests, stepper motors move in “steps”. They are used in applications where a precise and slow approach is required. In stepper motors, the rotor is surrounded by electromagnetic coils which energize in steps as the rotor rotates. They are used in 3D printers where precise position control is required in steps. Since the stepper motor works in steps, it has a low speed but it offers a high torque. There are fundamentally two types of stepper motors:

1. Unipolar

In a unipolar stepper motor, the coils are grouped into different phases which are energized one by one. This means that only half of the coils would be energized at a time hence the torque would be less.

2. Bipolar

In a bipolar stepper motor, the coils are again grouped into different phases but this time, one phase gets the voltage with normal polarity while the other phase gets it with negative polarity. Basically, the currents are reversed. This is achieved via a H-bridge. Hence, bipolar stepper motors have a greater torque than unipolar ones.

Since now you know what are the basic types of motors and what key parameters set them apart, you can definitely choose the right kind of motor for your project based on your application. Here are some of the most common Arduino applications which use the main three types of motors.

How to run a toy dc motor by using arduino

One problem with servos is that they cost a lot more than DC motors.

How to run a toy dc motor by using arduino

How to convert a DC motor to a Servo motor:

The basic idea behind converting a DC motor to servo is to find the position of the shaft and apply a DC voltage to get the Shaft to the expected position.

The below diagram illustrates the idea:

Controlling a DC motor in Servo mode:

  • Mega or Uno
  • L293 Motor controller
  • DC motor
  • Potentiometer

How to run a toy dc motor by using arduino

//Arduino code to control angle of a motor shaft using a potentiometer for feedback

//Please use a low rpm motor. Not more than about 500 rpm.

//1. Fix the shaft of the potentiometer to the motor shaft.You might like to use a slightly flexible coupling

//to do this, otherwise even a slight misalignment may cause trouble.

//2. Fix the body of the potentiometer to a rigid surface such as the body of the motor, //so that when the motor shaft turns, only the potentiometer shaft turns with it.

//3. Now we can read the potentiometer value to get the angle of the motor shaft //Look at my youtube video to see how I did this. In my video, I fixed the BODY of the potentiometer //to the motor shaft. It will be better to fix the SHAFT of the potentiomter to the motor

//shaft if you can do it properly

//Fix santa’s hand to the motor shaft so that it does not interfere with the potentiometer movement

//we will read the potentiometer value on analog pin 5

#define POT_VALUE_MAX 700

// potentiometer reading when motor shaft is at 180 degree position.

//You will need to fill this value according to your setup.See below.

#define POT_VALUE_MIN 200

//potentiometer reading when when motor shaft is at 0 degree position.

//You will need to fill this value according to your setup.See below.

//To fill up the correct values, first turn the motor shaft manually to 0 degree position.

//Now read the potentiometer value and edit the #define POT_VALUE_MIN line with your pot reading.

//Next manually move the motor shaft to 180 degree position,

//read the pot value and edit #define POT_VALUE_MAX line with your pot reading.

#define PERM_ERROR 3 //the max permissible error in degrees. In my potentiometer, a turn only about 3 degrees

//on the potentiometer shaft causes any real change in the ohmic reading. You can adjust this error

//value as required. If PERM_ERROR is very small, the shaft will keep hunting left and right as the //analogRead() of the potentiometer pin keeps fluctuating slightly

#define MAX_ANGLE 180 //we will allow our motor to turn by a maximum angle of 180 degrees

Many of our customers intend to use our motors with battery power supplies, which can range from the most simple of designs to complex handheld devices where the battery powers a multitude of electronics.

Here we’ll look at some of the common questions we see from battery users and highlight some of the potential pitfalls that need to be considered. Most of the article applies to all DC motors, including our gear motors and vibration motors, and we will point out any key differences. Note that help driving brushless motors and driving LRAs is better found in our Application Bulletins.

What do I need?

Other than the battery and the motor? Nothing.

Well, that may be a bit simplistic – you dramatically reduce your flexibility and options with so few components. However, there are many applications where the motor just needs to run in one direction at one speed and can be switched on / off by disconnecting the power:

Don’t want to continually plug/unplug the battery? Try a simple switch:

How to run a toy dc motor by using arduino

Get in touch

Speak to a member of our team.

Motor catalogue

Looking for our products?

Reliable, cost-effective miniature mechanisms and motors that meet your application demands.

How to run a toy dc motor by using arduino

We could look at even more complicated circuits and how they interact with the motor, but this article is focusing on using batteries as a power source. So to keep it simple we’ll use the circuit above.

How Long Will It Last?

To calculate how long a battery will last, we need two figures; the battery’s capacity and how much current will be drawn by the motor.

Batteries measure their capacity in milliamp hours, mAh. This states how many hours the battery can supply 1 mA of current, or how many mA of current it can supply for one hour.

The current draw depends on the motor, for this, we can refer to the datasheets found on the product pages. The Typical Performance Characteristics graph shows how the current varies with the input voltage (vibration motors) or with the torque load (DC and gearmotors, at rated voltage).

This provides us with a good start, but in reality there are several other factors that affect the operational lifetime.

Common Pitfalls

Battery Voltage

Not all batteries are created equal, make sure the voltage is at an appropriate level. For example, while a 3V motor will likely run from a 1.5V AA battery but you will get better performance connecting two AA batteries in series to create a 3V supply. Conversely, if the motor is rated at 1.5V using a 3V battery runs the risk of immediate damage the motor (as would anything above the Maximum Operating Voltage).

The reduced voltage causes motors to turn slower. This reduces the torque handling capabilities for DC and gearmotors, whilst causing vibration motors to vibrate less.

Also, some battery designs have different voltages – even though classed as, for example, AA. Rechargeable batteries are the worst offenders for this, with most popular types offering 1.2V.

Battery Capacity

The value of mAh is measured under very specific test conditions and are not representative of all scenarios.

In real applications, whilst the battery may perform to its rating with low and intermittent current draws, it will discharge much quicker with higher current draws. A battery with 1600 mAh rating will provide 1 mA for close to 1600 hours, however, it will not provide 1.6A for a full hour.

Consider adding a second battery in parallel, this will keep the supply voltage the same but increase the capacity. Laptop batteries commonly use 4 cells in series to increase the voltage, and two parallel sets of the 4 series cells to increase the capacity.

Battery Voltage Shift

As batteries discharge, their voltage reduces. This effect will be more noticeable for certain types of battery and is generally not a huge factor, but if your application is designed close to the limits it may cause failure.

Take particular note of the difference between the Typical Start Voltage (when the motor typically starts) and the Certified Start Voltage (where it is guaranteed). For DC and gearmotors the stall torque will reduce.

If you’re concerned about this, use a battery above the level you require (e.g. a 3.6V battery) and voltage regulator set for your desired constant voltage (e.g. 3YV).

Start Current

Motors draw more current when they start (to overcome the inertia of the mass or friction in gears) than during normal operation, therefore they will reduce the battery life more than normal operation.

The datasheets include the value Maximum Start Current, but the time taken for the current draw to reduce to normal operation varies between each motor. This makes calculating the exact running time very difficult.

Discover more

Resources and guides

Discover our product application notes, design guides, news and case studies.

  • Tutorial: Enabling the Slider Function
  • Reading the Motor Constants from Typical Performance Characteristics
  • Quick LRA Debugging
  • Performance Improvements for Using Haptic Effects
  • Olympic Vibrations
  • New Xbox One Controller Increasing Haptic Feedback Offering

Case studies

Explore our collection of case studies, examples of our products in a range of applications.

Precision Microdrives

Whether you need a motor component, or a fully validated and tested complex mechanism – we’re here to help. Find out more about our company.

Contact us

You need our support. We’re here to help.

Motor products are difficult to understand, specify, validate and integrate into end application. The industry has no standards and suppliers typically offer only fragments of advice.

We know what you don’t and can mitigate your motor design, manufacturing and supply risks.

Get in touch with our team today.

Precision Microdrives™ – Your trusted mechanism design & manufacturing partner

A direct current (DC) motor is a type of electric machine that converts electrical energy into mechanical energy. DC motors take electrical power through direct current, and convert this energy into mechanical rotation.

DC motors use magnetic fields that occur from the electrical currents generated, which powers the movement of a rotor fixed within the output shaft. The output torque and speed depends upon both the electrical input and the design of the motor.

How DC motors work

How to run a toy dc motor by using arduino

The term ‘DC motor’ is used to refer to any rotary electrical machine that converts direct current electrical energy into mechanical energy. DC motors can vary in size and power from small motors in toys and appliances to large mechanisms that power vehicles, pull elevators and hoists, and drive steel rolling mills. But how do DC motors work?

DC motors include two key components: a stator and an armature. The stator is the stationary part of a motor, while the armature rotates. In a DC motor, the stator provides a rotating magnetic field that drives the armature to rotate.

A simple DC motor uses a stationary set of magnets in the stator, and a coil of wire with a current running through it to generate an electromagnetic field aligned with the centre of the coil. One or more windings of insulated wire are wrapped around the core of the motor to concentrate the magnetic field.

The windings of insulated wire are connected to a commutator (a rotary electrical switch), that applies an electrical current to the windings. The commutator allows each armature coil to be energised in turn, creating a steady rotating force (known as torque).

When the coils are turned on and off in sequence, a rotating magnetic field is created that interacts with the differing fields of the stationary magnets in the stator to create torque, which causes it to rotate. These key operating principles of DC motors allow them to convert the electrical energy from direct current into mechanical energy through the rotating movement, which can then be used for the propulsion of objects.

Who invented the DC motor?

This amazing piece of electrical equipment has revolutionised our lives in many ways, but who invented the DC motor? As with all major innovations, there are many people who had a role to play through the development of similar mechanisms.

In the US, Thomas Davenport is widely celebrated as the inventor of the first electric motor, and undoubtedly he was the first to patent a useable electric motor in 1837. Davenport, however, was not the first person to build an electric motor, with various inventors in Europe having already developed more powerful versions by the time Davenport filed his patent.

In 1834, Moritz Jacobi had presented a motor that was three times as powerful as the one Davenport would later patent, while Sibrandus Stratingh and Christopher Becker were the first to demonstrate a practical application for an electric motor, by running a small model car in 1835.

The first practical DC motor was invented some years later in 1886 by Frank Julian Sprague, whose invention lead to the first motor powered trolley system in 1887, and the first electric elevator in 1892. Sprague’s DC motor was a hugely significant development, leading to a variety of applications which would reshape the face of industry and manufacturing.

Types of DC Motors

So far, this guide has broadly explained how DC motors work, the history of these mechanisms, and what they look like. While the principles are the same across variants, there are actually several different types of DC motors, which offer specific advantages and disadvantages over each other.

This section of the guide will look at the four main types of DC motor – brushless, brushed, shunt, and series.

DC motor control using MATLAB GUI and Arduino:

DC Motor Control using MATLAB GUI and Arduino fully explained- in my previous three tutorials I explained,

In my previous tutorial I covered the extreme basics and I explained each and every detailed to control an LED using the Matlab GUI. Now, I think we can try something intermediate, In this tutorial we will discuss how to control a DC motor from MATLAB by creating a GUI graphical user interface using Arduino.

Amazon Links:

Other Tools and Components:

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

DC motor Interfacing with Arduino using L293D, Circuit Diagram:

How to run a toy dc motor by using arduino

In the circuit diagram I used the L293d motor driver and a toy DC motor. The L293d motor driver is capable of controlling 2 DC motors while in our case we are using only one side of the l293d Motor Driver because that I am using only one motor and the enable of first pin that is the enable pin of l293d is connected to the digital pin 8 of the Arduino and the input of the l293d are connected to the 6 and 7pin of the Arduino.

DC motor interfacing with MATLAB:

Now we will create GUI for the DC motor in MATLAB, so, first type guide and GUI interface will appear. Now we will design our GUI:

How to run a toy dc motor by using arduino

I need three buttons for this GUI so if I press the first button the motor should run clockwise, if I press the second button the motor should run anti-clockwise, and if I press the third one the motor should stop. Now to create these buttons just select the button and drag it and click on the button and you can change the title and tag of the button as explained in my previous LED control tutorial. Change the names of the button to clockwise, anticlockwise, and stop.

How to run a toy dc motor by using arduino

We are also going to control the speed of the motor. So, I am going to use a slider and the speed of the motor can be seen in the text box next to the slider, that’s it, and I am going to do some changes to the slider that the maximum value should be 5 for the slider.

How to run a toy dc motor by using arduino

Then we will save the GUI by click on the save button in the GUI with the name dc_motor and click on the save button.

How to run a toy dc motor by using arduino

After clicking on the save button the code will appear.

How to run a toy dc motor by using arduino

The first thing, we have to initialize some variables, so, whatever the previous function that is in the memory that will be cleared if I give the clear all function, and I am going to assign a global variable and this global variable will have Arduino.

How to run a toy dc motor by using arduino

If you are into electronics, then you must have heard about the arduino board. Arduino boards are in many types but the most popular one is known as Arduino Uno. There are number of simple application of the board you will find such as LED Blinker, Arduino motor control and many more which can easily be made through the Uno board.

In Motor control application by arduino, you will find number DC motors everywhere like toys, fans, tools etc. And, the torque of these DC motors is based on their physical specifications. The Arduino motor control uses DC motors which changes the direction as we change the direction of dc current which can be done easily with an arduino board.

How to run a toy dc motor by using arduino

Arduino Motor Control Circuit Diagram

Components needed of Arduino Motor Control Circuit :

  • A small DC motor (Shunt DC Motor)
  • An Arduino board
  • L293D Motor Driver (H Bridge)
  • Switches
  • Variable resistor (Preset)

This Uno board is uploaded an arduino code according to which it establishes the arduino dc motor direction control. The below code can be used in order to control the direction of DC motor You can get a number of Arduino codes online. All you have to do is upload it in your arduino board using Arduio software.

Program for Arduino Motor Control

Working of Arduino Motor Control

Arduino motor control is used in DC motors for efficiently controlling the speed and direction of the motor without the help of integrated motor driver.

  • For adjusting the speed of the motor, the one pin of the motor is attached to the analog pin of the arduino. And, when the connections are made the motor moves in the normal forward direction in our desired speed.
  • Then, when the button connected to another of arduino is pressed then the direction in which the motor was moving is reversed. And, until the button is not released it keeps on moving in the same direction.
  • Transistors are there to efficiently control the forward direction of DC motor.
  • And, when the button is presses another set of transistors work to provide reverse direction to the motor, until the button is released.

Servo Motor Control By Arduino

With an arduino You can also control Servo motor which work on direct current but need an additional data input which decides which angle the servo should hold.. They basically have a separate field winding and the armature winding of the direct current (DC) source. These types of motors are used more often than others because they provide a fast and controlled command to the motor. The signal or command generated from these motors are very accurate that is why the response of the motor is quick and rapid. They also respond to the stop and start command in fraction of seconds because of the separate winding of the DC source. You will mainly found these types of servo motors in the numerically controlled equipment and simple appliances.

Short description of Arduino Uno board

The arduino motor control is established using an arduino Uno board. Uno board is the most commonly used type of arduino board. The reason it is most preferred board in electronics is that it has all the essential elements in it. Like,

DC motors

The DC motors are used for direction purpose which are operated at the signal obtained by arduino. The purpose of choosing DC motor in Arduino Motor Control is that it changes the rotational direction as we change the direction of DC Current.

How to run a toy dc motor by using arduino

This tutorial, we will learn about controlling of DC Motor with Arduino in Proteus ISIS. DC Motor is commonly used in engineering projects. It is normally used to control the speed and rotating electrical energy into mechanical energy. We can move the DC motor at any desired rotation which is not possible in case of other motors. We are going to Control DC Motor with Arduino and will design the simulation in Proteus ISIS. First of all, we will have a look at simple control of dc motor with arduino in Proteus ISIS.

How to run a toy dc motor by using arduino

What is DC Motor ?

A Direct Current (DC) Motor is a type of electric machine that converts Electrical energy into Mechanical energy. The term ‘DC motor’ is used to refer to any rotating electrical machine that converts direct current Electrical Energy into Mechanical Energy.

How to run a toy dc motor by using arduino

DC motors can vary in size and power from small motors in toys and appliances to large mechanisms that power vehicles, pull elevators and hoists, and drive steel rolling mills. DC Motors are used in industrial machines, Electric bikes, Wheelchairs, etc. There are situations when we need to run a DC motor at a constant speed.

Required components


DC motors normally have just two leads, one positive and one negative, one of them goes to Vcc, other one to diode and commonly connected to the transistor through 270ohm resistor while goes to digital PIN 9 of Arduino board. The Rx pin of the Arduino is connected to the Tx pin of the Virtual Terminal and the Tx pin of the Arduino is connected to the Rx pin of the Virtual Terminal which is shown by the right side of the Proteus window(instrument mode).

How to run a toy dc motor by using arduino

Arduino Sketch

How to run a toy dc motor by using arduino

Then get the hex file from the code.( At the bottom of screen of the uploading program select the file path i.e.” “C:\Users\osuser\AppData\Local\Temp\arduino_build_435892/DC_motor .ino.hex”” )

Then double click “ARDUINO UNO R3″, we will see Edit Component window after that Browse it in Program File/ Put file path which selecting from the arduino uploading window, then click OK.

How to run a toy dc motor by using arduino


At the bottom of screen of Proteus window we will see Play, Stop, Pause buttons. By pressing Play button simulation will start. Remember that Arduino IDE will not compile code if Simulation is running and it will not show any error.

The DC motor will rotate with different speeds according to the value (0 to 250) received via the serial port (virtual terminal). You need to enter a value between 0 and 255 in the virtual Monitor. whenever you click the simulation button the simulation button then data that is send by the Arduino is displayed on the Terminal window as shown in the following figure.

How to run a toy dc motor by using arduino

I hope by reading this project you know about basics knowledge of dc motor as well as controlling a speed with Arduino in serial monitor(virtual monitor). if you have any problem, do ask in comments. till then take care .

If you are in a need to control the speed of a Dc Motor for one of your projects but you don’t care about the direction then the easiest and cheapest way is through a Darlington transistor like TIP120. Because Arduino cannot supply enough power to the motor(only 40mA maximum) we have to use external power supply. A small dc motor will require around 500mA at full speed so if you try to drive it from an Arduino pin probably a damage would occur. And of course there is a possibility your motor may require 12v or higher voltage so external power supply is the only way to go.

Transistors are like digital switches, they have 3 pins , the Collector(C), the Base(B) and the Emitter(E). Whenever we apply voltage to base, the transistor turns on and allows current to flow through emitter and collector. So by applying small current we can control larger currents. In our case we are going to use digital pin 9 which is PWM. This means that it turns high so many times as the value we pass. More about pulse width modulation here. In this way we are controlling the speed. Remember that the value we are getting from the potentiometer ranges from 0 to 1023 and pwn needs to be from 0 to 255, so we need to convert it. Just divide the reading value by 4.

How to run a toy dc motor by using arduino

How to run a toy dc motor by using arduino

Also in our circuit we are going to use a diode for protection. Diodes protect from reverse voltage and its a good idea to use them in our circuits.