In this blog we learn how to run a stepper motor with the help of Arduino UNO R3 and L293D IC (Motor Driver IC).The stepper motor is used in electronics and electro-mechanical equipment’s like 3D printers, CNC machine, hard disk drives, robotics, antennas, telescopes etc.


Parts required:

  1. Arduino UNO
  2. Bipolar stepper motor
  3. Jumper wire
  4. Breadboard
  5. L293D IC


How to interconnect Arduino, stepper motor and L293D IC-


1-  Place the L293D motor control IC to breadboard as shown in figure-Pin 1 of L293D IC to pin (10,E) of breadboard


2-   Connect the Pin No-1,Pin No-9 and Pin no-16 of L293D IC to +5 Volt supply from Android by jumper wires  as shown in figure


a)   Connect Pin(10,C) of breadboard /Pin 1 of L293D IC to +ve terminal of breadboard

b)   Connect Pin(10,H) of breadboard / Pin 16 of L293D IC to +ve terminal of breadboard

c)   Connect Pin(17,H) of breadboard / Pin 9 of L293D IC to +ve terminal of breadboard

d)   Connect the +ve terminal of breadboard to Arduino 5V Pin terminal




3-   Connect Pin 4,Pin 5,Pin12,Pin13 of L293D IC to Breadboard and Arduino by jumper wires as shown in figure


a)   Connect Pin (13,H) of breadboard / Pin 13 of L293D IC to negative terminal of breadboard

b)   Connect Pin (14,H) of breadboard / Pin 12 of L293D IC to negative terminal of breadboard

c)   Connect Pin (13,C) of breadboard / Pin 4 of L293D IC to negative terminal of breadboard

d)   Connect Pin (14,C) of breadboard / Pin 5 of L293D IC to negative terminal of breadboard

e)   Connect negative terminal of breadboard to Gnd terminal of Arduino

f)   Interconnect the negative terminals breadboard




4-   Connect Pin 3,Pin 6, Pin 11,Pin14 of L293D IC to Bipolar Stepper Motor by wires


a)   Connect Pin (12,C) of breadboard/Pin3 of L293D IC to Bipolar Stepper Motor

b)   Connect Pin (13,C) of breadboard/Pin4 of L293D IC to Bipolar Stepper Motor

c)   Connect Pin (15,H) of breadboard/Pin11 of L293D IC to Bipolar Stepper Motor

d)   Connect Pin (10,H) of breadboard/Pin14 of L293D IC to Bipolar Stepper Motor




5-   Connect Pin 2,Pin 7,Pin 10, Pin 15 of L293D IC to Arduino by Jumper Wires


a)   Connect Pin (11,B) of breadboard/Pin2 of L293D IC to Arduino Pin 2

b)   Connect Pin (16,B) of breadboard/Pin7 of L293D IC to Arduino Pin

c)   Connect Pin (11,G) of breadboard/Pin10 of L293D IC to Arduino Pin

d)   Connect Pin (11,G) of breadboard/Pin15 of L293D IC to Arduino Pin




6-   Connect Power Source To breadboard for stepper motor-Connect positive terminal of power source to Pin 8 of L293D IC by wire




7-   Install the following code in Arduino Board


#include <Stepper.h>

int in1Pin = 12;

int in2Pin = 11;

int in3Pin = 10;

int in4Pin = 9;

// change this to the number of steps on your motor

#define STEPS 512

Stepper motor(STEPS, in1Pin, in2Pin, in3Pin, in4Pin);

void setup()

{

  pinMode(in1Pin, OUTPUT);

  pinMode(in2Pin, OUTPUT);

  pinMode(in3Pin, OUTPUT);

  pinMode(in4Pin, OUTPUT);

  // this line is for Leonardo's, it delays the serial interface

  // until the terminal window is opened

  while (!Serial);

  Serial.begin(9600);

  motor.setSpeed(20);

}

void loop()

{

  if (Serial.available())

  {

    int steps = Serial.parseInt();

    motor.step(steps);

  }

}



8-   Run it and enjoy…………