Interfacing DC Motor With Arduino!!..

Haiii,

This post helps the beginners to interface DC motor with arduino.DC motor can be bought from our online store by clicking here.

Below figure shows the quick view of Arduino Uno.

Features

  • ATmega328P microcontroller
  • Input voltage – 7-12V
  • 14 Digital I/O Pins (6 PWM outputs)
  • 6 Analog Inputs
  • 32k Flash Memory
  • 16Mhz Clock Speed

L293D [Motor Driver]

  • L293D is a motor driver IC.
  • The L293 and L293D devices are quadruple high- current half-H drivers.
  •  The L293D is designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V.

Below shows the picture used to interface the DC Motor with Arduino

CONNECTION

  1. The two wires of the dc motor is connected to the screw terminal block of L293D
  2.  The C1-A and C2-A pins  of the L293D are connected to the 8th and 9th pin of arduino.
  3. DC motor works under 12v.So the 12v and Gnd pin of the driver is connected to arduino. For getting 12v in arduino , give additional 12v supply for arduino.

//Sample Code to check the working of DC Motor

int motorpin1 = 3;                 

int motorpin2 = 4;                  

void setup () {

  pinMode(motorpin1,OUTPUT);       

  pinMode(motorpin2,OUTPUT);      

}

void loop () {

  digitalWrite(motorpin1,LOW);

  digitalWrite(motorpin2,HIGH);

}

TESTING

STEP 1:

Connect the A to B  cable to the USB port of a computer and make sure that the port has been detected by checking the Device Manager option.

STEP 2:

Open two Arduino IDE window and Select Arduino UNO as Board and select the appropriate COM port.

  • Board: Tools > Board > Arduino/Geniuno UNO.

STEP 3:

  • Port: Tools > Port in Arduino.

STEP 4:

  1. Compile and upload this program to your Arduino Uno board via Arduino IDE
  2. After completing the uploading the motor rotates in one direction

 

NOTE:

If you wish to change pin numbers then you can change the pins of Arduino.We can connect two motors on either side of the motor driver .

Leave a comment