[Project 16] – DC motor speed and direction control using arduino

In this project we will control DC motor speed and direction control using potentiometer and L293D (quadruple half-h drivers) with the Arduino.  I will use arduino uno in the circuit design program. I use usually arduino mega 2560. You can use the other arduino cards. Good Luck.

Circuit:


[Project 16] - DC motor speed and direction control using arduino 99

Materials:


Arduino Uno/Mega  x1
Breadboard  x1
Potentiometer (5Kohm-10Kohm)  x1
Toggle Switch  x1
L293D  x1
220 ohm Resistor  x1
DC Motor  x1
Battery (for Dc Motor)  x1
Jumper Cable
 

L293D Pins:


[Project 16] - DC motor speed and direction control using arduino L293D datasheet  pins

Program:

//  letsarduino.com
//  [Project 16] - DC motor speed and direction control using arduino
const int switchPin = 2; 
const int motor1Pin = 5; 
const int motor2Pin = 4; 
const int enablePin = 3; 
const int pot = 0;
int value = 0;

void setup()  
{ 
pinMode(switchPin, INPUT);

pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
}
void loop()  
{ 
  value=analogRead(pot);
  value=map(value,0,1024,0,255);
  analogWrite(enablePin,value);
  delay(10);
  
if (digitalRead(switchPin) == HIGH) 
{
  digitalWrite(motor2Pin, HIGH); 
  digitalWrite(motor1Pin, LOW); 
}
else 
{
digitalWrite(motor1Pin, HIGH); 
digitalWrite(motor2Pin, LOW); 
}
}


 

Project Related Images:


[Project 16] - DC motor speed and direction control using arduino 993[Project 16] - DC motor speed and direction control using arduino 99



 

You may also like...