Connecting Simple DC Motor In Arduino Mega 2560

Introduction

  • In this article, I will explain about connecting simple DC Motor in Arduino Mega 2560.
  • It can work with the connection of the PN 2222 transistor.
Parts Of Lists:
  • Arduino Mega 2560
  • DC Motor
  • PN2222 Transistor
  • Diode
  • 270-ohm Resistor
  • LED
  • Bread Board.
PN2222 Transistor
  • It can be used for low power and medium power amplifying.
  • It is frequently used as a small-signal transistor.
  • It can have the following three pins.
    • First pin = Collector
    • Second pin = Base
    • Third pin = Emitter
  •  


    Figure 1: PN 2222 Transistor
DC motor:
  • DC Motor that converts the direct current electrical power to the mechanical power.
  • A DC motor's speed can be controlled over a wide range, using either a variable supply voltage or by changing the strength of current in its field windings.
  • Small DC motors are used in tools, toys, and appliances.
 
 
Figure 2: Dc Motor
 
Connection:
 
Step 1: Connection From DC motor to board
  • Connect the red color wire to the positive of the diode pin
  • Connect the black color wire to the negative of the diode pin.
  • Connect the negative pin to the interconnect of the transistor of the emitter.
Step 2: Connection From Transistor to Board
  • Connect the base pin to the digital pin 05 of the Arduino Mega 2560.
  • Connect the collector pin to the Gnd of the board.
Step 3: LED Connection to Board
  • Positive pin to the 12
  • Negative pin to the Gnd.
Programming
  1. int motor=5;      
  2. int led=12;      
  3.       
  4. void setup()      
  5. {      
  6.   pinMode(led,OUTPUT);      
  7.   pinMode(motor,OUTPUT);      
  8.   Serial.begin(9600);      
  9.   if(! Serial);      
  10.   Serial.println("Speed up to 0 to 255");      
  11. }      
  12. void loop()      
  13. {      
  14.   if(Serial.available())      
  15.   {      
  16.     int speed=Serial.parseInt();      
  17.     if(speed >=0 && speed <=255)      
  18.     {      
  19.       digitalWrite(led,HIGH);      
  20.     }       
  21.     else {      
  22.       digitalWrite(led,LOW);      
  23.     }      
  24.       analogWrite(motor,speed);      
  25.     }      
  26.   }     
Explanation
  • In this article I have explained about the connection of simple DC Motor using Arduino Mega 2560
  • Normally the DC motor can run in the high, so it will control and give the limited speed.
  • When the DC motor is in high speed, it will glow the LED.
  • When the DC motor is in low speed, it cannot glow the LED.
Output
 
 
Figure 3 : Output