Proper understanding of L293D Driver// Voltage Drops // Line Follower


I am currenlty building a line follower using Atmega328P, Five CNY70 sensors, L293D H-bridge and two DC Motors. I've build my prototype on board and it works as expected (surprise :smiley: ).

I wanted to control the speed of the motors by manipulating the values of analogWrite function and it also works. The thing is, even though I provide 5V voltage to L293D PIN8 (VCC2), the maximum volatege on the DC motor I can acquire is ~3.2V.

At this point the Atmega, CNY70 and VCC1 of L293D are powered from Arduino UNO Board (5V) and I've got external power supply of 5V which is connected to VCC2 of L293D.

Is it normal for L293D to loose some of the voltage? Should I just change the external power supply for higher? Or should I rather look for some mistakes in the circuit?

My code is:

//Motor A (right)
const int motorPin1  = 11;  // Pin 14 of L293
const int motorPin2  = 10;  // Pin 10 of L293

//Motor (left)
const int motorPin3  = 9; // Pin  7 of L293
const int motorPin4  = 3;  // Pin  2 of L293

const int drivePower = 120;
const int narrowTurnPower = 180;
const int sharpTurnPower = 255;

// Sensors
int sensorPin0 = A0;
int sensorPin1 = A1;
int sensorPin2 = A2;
int sensorPin3 = A3;
int sensorPin4 = A4;

int sensorValue0 = 0;
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
int sensorValue4 = 0;

void setup(){
    //Set pins as outputs
    pinMode(motorPin1, OUTPUT);
    pinMode(motorPin2, OUTPUT);
    pinMode(motorPin3, OUTPUT);
    pinMode(motorPin4, OUTPUT);
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, LOW);

void printSensors() {
  Serial.print("A0: ");
  Serial.print("A1: ");
  Serial.print("A2: ");
  Serial.print("A3: ");
  Serial.print("A4: ");

void loop(){
  sensorValue0 = analogRead(sensorPin0);
  sensorValue1 = analogRead(sensorPin1);
  sensorValue2 = analogRead(sensorPin2);
  sensorValue3 = analogRead(sensorPin3);
  sensorValue4 = analogRead(sensorPin4);


  if (sensorValue2 < 5) {
    analogWrite(motorPin1, drivePower);
    analogWrite(motorPin3, drivePower);
  else {
    analogWrite(motorPin1, 0);
    analogWrite(motorPin3, 0);

  if (sensorValue1 < 5) {
    analogWrite(motorPin1, narrowTurnPower);

  if (sensorValue3 < 5) {
    analogWrite(motorPin3, narrowTurnPower);

  if (sensorValue0 < 5) {
    analogWrite(motorPin1, sharpTurnPower);

  if (sensorValue4 < 5) {
    analogWrite(motorPin3, sharpTurnPower);
    Serial.println("SHARP TURN");


I know the code is not perfect at this point, it is more to test the circuit, rather than the final version.

Thanks everyone in advance!


You'd be better off with a FET bridge - the L293 is positively antediluvian.

Thanks for the fast answer! And for the suggestion too :wink:

Nevertheless, assuming I would stay with L293D, should a little bit higher voltage on VCC2 solve the matter?

Yes, you can increase the supply voltage to compensate.

Thanks a lot!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.