0% found this document useful (0 votes)
74 views5 pages

L293D Ic With DC Motor: Information

The L293D IC is a dual H-bridge motor driver that can control two DC motors or one stepper motor independently. It has two power input pins, Vcc1 for the internal logic at 5V and Vcc2 for driving the motors from 4.5-36V. The direction and speed of each motor is controlled using four I/O pins per channel - two pins for direction and one enable pin for PWM speed control. The code example shows how to use these pins to change the direction and accelerate/decelerate the motors.

Uploaded by

Neeraj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views5 pages

L293D Ic With DC Motor: Information

The L293D IC is a dual H-bridge motor driver that can control two DC motors or one stepper motor independently. It has two power input pins, Vcc1 for the internal logic at 5V and Vcc2 for driving the motors from 4.5-36V. The direction and speed of each motor is controlled using four I/O pins per channel - two pins for direction and one enable pin for PWM speed control. The code example shows how to use these pins to change the direction and accelerate/decelerate the motors.

Uploaded by

Neeraj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

L293D IC WITH DC

MOTOR
INFORMATION:-

The L293D is a dual-channel H-Bridge motor driver capable of driving a pair of


DC motors or one stepper motor.

That means it can individually drive up to two motors making it ideal for
building two-wheel robot platforms.

The L293D motor driver IC actually has two power input pins viz. ‘Vcc1’ and
‘Vcc2’.

Vcc1 is used for driving the internal logic circuitry which should be 5V.From
Vcc2 pin the H-Bridge gets its power for driving the motors which can be 4.5V
to 36V. And they both sink to a common ground named

Pin 2,7,10,15 are input directional control pins


Pin 3,6,11,14 are output terminal pins

The speed control pins viz. ENA and ENB are used to turn ON, OFF and control
speed of motor A and motor B respectively.

Analogwrite function write all analog values in range 0 to 255

Digitalwrite function write a high or low values to a digital pins.

CODE
// Motor A connections

int enA = 9;

int in1 = 8;

int in2 = 7;

// Motor B connections

int enB = 3;

int in3 = 5;

int in4 = 4;

void setup() {

// Set all the motor control pins to outputs

pinMode(enA, OUTPUT);

pinMode(enB, OUTPUT);

pinMode(in1, OUTPUT);

pinMode(in2, OUTPUT);

pinMode(in3, OUTPUT);

pinMode(in4, OUTPUT);

// Turn off motors - Initial state

digitalWrite(in1, LOW);

digitalWrite(in2, LOW);

digitalWrite(in3, LOW);

digitalWrite(in4, LOW);
}

void loop() {

directionControl();

delay(1000);

speedControl();

delay(1000);

// This function lets you control spinning direction of motors

void directionControl() {

// Set motors to maximum speed

// For PWM maximum possible values are 0 to 255

analogWrite(enA, 255);

analogWrite(enB, 255);

// Turn on motor A & B

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

digitalWrite(in3, HIGH);

digitalWrite(in4, LOW);

delay(2000);

// Now change motor directions

digitalWrite(in1, LOW);

digitalWrite(in2, HIGH);

digitalWrite(in3, LOW);

digitalWrite(in4, HIGH);

delay(2000);

// Turn off motors


digitalWrite(in1, LOW);

digitalWrite(in2, LOW);

digitalWrite(in3, LOW);

digitalWrite(in4, LOW);

// This function lets you control speed of the motors

void speedControl() {

// Turn on motors

digitalWrite(in1, LOW);

digitalWrite(in2, HIGH);

digitalWrite(in3, LOW);

digitalWrite(in4, HIGH);

// Accelerate from zero to maximum speed

for (int i = 0; i < 256; i++) {

analogWrite(enA, i);

analogWrite(enB, i);

delay(20);

// Decelerate from maximum speed to zero

for (int i = 255; i >= 0; --i) {

analogWrite(enA, i);

analogWrite(enB, i);

delay(20);

// Now turn off motors

digitalWrite(in1, LOW);

digitalWrite(in2, LOW);
digitalWrite(in3, LOW);

digitalWrite(in4, LOW);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy