Tuesday, May 29, 2018

Programming the 5V DC Motor and controlling speed using the L293D motor


This blog is about using the PWM signals available on the Arduino Nano to control the speed of the Hobby DC Motor 5V.

Parts required :
Hobby DC Motor
L293D Motor Driver.
Arduino Nano  and pair of wires.

Code is fairly simple :

int enable2 = 9;
int in3 = 10;
int in4 = 11;

void setup()
{

  pinMode(enable2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);

}
void loop()
{
  analogWrite(enable2, 138); // Any value between 0 and 255
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  /*delay(10000);
  analogWrite(enable2, 200); // Any value between 0 and 255
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(10000); 
  */
  
}

Connections :
Nano :
Pin 10 and 11 to Inputs of the L293D.
Pin 9 of Arduino to Enable Pin of the L293D.

5V power to supply both the Vss and the Power to the Motor.







0 Comments:

Post a Comment

<< Home