Using a l293d motor control shield without mounting

Hello
I wanted to use a l298n for a project of mine to control 2 dc motors but I received a l293d motor control shield instead

Is there a way to use the l293d without mounting it on arduino uno and to use it s a replacement for l298n?
This is the circuit diagram

#include <Servo.h> //include servo.h library
Servo esc; 
const int trigPin1 = 2;
const int echoPin1 = 3;
const int trigPin2 = 4;
const int echoPin2 = 5;
const int trigPin3 = 6;
const int echoPin3 = 7;
int irpin =8;

long duration1;
long duration2;
long duration3;
int distanceleft;
int distancefront;
int distanceright; 

int a=0;
char cmnd;

void setup() {
  pinMode(trigPin1, OUTPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(trigPin3, OUTPUT);// Sets the trigPin as an Output
  pinMode(echoPin1, INPUT); // Sets the echoPin as an Input
  pinMode(echoPin2, INPUT);
  pinMode(echoPin3, INPUT);
  pinMode(irpin, INPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(A0, INPUT);
  Serial.begin(9600);
  esc.attach(13); 
  esc.writeMicroseconds(1000);
  delay(2000);
}
void loop() {
  digitalWrite(trigPin1, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin1, LOW);
  duration1 = pulseIn(echoPin1, HIGH);
  distanceleft = duration1 * 0.034 / 2;
  Serial.print("Distance1: ");
  Serial.println(distanceleft);
  digitalWrite(trigPin2, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin2, LOW);
  duration2 = pulseIn(echoPin2, HIGH);
  distancefront = duration2 * 0.034 / 2;
  Serial.print("Distance2: ");
  Serial.println(distancefront);
  digitalWrite(trigPin3, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin3, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin3, LOW);
  duration3 = pulseIn(echoPin3, HIGH);
  distanceright = duration3 * 0.034 / 2;
  Serial.print("Distance3: ");
  Serial.println(distanceright);
  int s = digitalRead(irpin);
  
  int val; 
  val= analogRead(A0); 
  val= map(val, 0, 1023,1000,2000);
  esc.writeMicroseconds(val);
  

  if(s==HIGH)
  { 
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    delay(1000);
    a=1;
    }
  if ((a==0)&&(s==LOW)&&(distanceleft <= 15 && distancefront > 15 && distanceright <= 15) || (a==0)&&(s==LOW)&&(distanceleft > 15 && distancefront > 15 && distanceright > 15))
  {
    digitalWrite(9, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(11, HIGH);
    digitalWrite(12,LOW);
  }
  if ((a==1)&&(s==LOW)||(s==LOW)&&(distanceleft <= 15 && distancefront <= 15 && distanceright > 15)||(s==LOW)&&(distanceleft <= 15 && distancefront <= 15 && distanceright > 15)||(s==LOW)&& (distanceleft <= 15 && distancefront > 15 && distanceright > 15)||(distanceleft <= 15 && distancefront > 15 && distanceright > 15))
  {
    digitalWrite(9, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    delay(100);
    a=0;
  }
  if ((s==LOW)&&(distanceleft > 15 && distancefront <= 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront > 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront <= 15 && distanceright > 15) )
  {
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
  }
  
while(Serial.available() > 0)

 {
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
  digitalWrite(12, LOW);
  
  cmnd = Serial.read();
  Serial.println(cmnd);

  
if( cmnd == 'F') // Forward
    {
      digitalWrite(9, HIGH);
      digitalWrite(10, LOW);
      digitalWrite(11, HIGH);
      digitalWrite(12, LOW);  
    }
  else if(cmnd == 'B') // Backward
    {
      digitalWrite(9, LOW);
      digitalWrite(10, HIGH);
      digitalWrite(11, LOW);
      digitalWrite(12, HIGH); 
    }
  
    else if(cmnd == 'R') //Right
    {
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
    }
    else if(cmnd == 'L') //Left
    {
    digitalWrite(9, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH); 
    }
    else if(cmnd == 'I') //Forward Right
    {
    digitalWrite(9, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    }
  else if(cmnd == 'J') //Backward Right
    {
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    }
   else if(cmnd == 'G') //Forward Left
    {
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, HIGH);  
    digitalWrite(12, LOW);
    }
  else if(cmnd == 'H') //Backward Left
    {
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH); 
    }}}

Sure you can use the shield, but I would not bother. Find a schematic for the shield so that you can identify the pin mapping. Then wire between the shield and Arduino with DuPont jumpers or solder wires.

The L29x drivers are a poor choice of driver for battery powered projects since they waste so much power as heat. The ancient technology in those drivers is very inefficient. Pololu has a great line of modern motor drivers. Pick a motor driver based on motor supply voltage and the motor stall current.

Please read the forum guidelines to see how to properly post code and some information on making a good post.

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in a code block.

Please go back and fix your original post.

Your shield is like this:

or like this:

It's the first one

This is your shield schematics: (Ref: http://wiki.sunfounder.cc/index.php?title=L293D_Motor_Driver_Shield)

I haven't tried the L293d, but with the L298N, you can even control 2 motors simultaneously by wiring them directly to Motor A, without using 2 Arduino ports for configuring Motor B. Set up one motor and connect the second motor in parallel.

*The only drawback of using 2 motors is that it will require more space for the battery in the project, and you'll need to increase the voltage. Using 2 motors requires more voltage; otherwise, you'll notice a significant decrease in power, force, and performance compared to using only 1 motor

.

In the picture, I see 3 motors. Honestly, with only 12 volts, it might be quite limited to move these two yellow motors. I have and use 18V, and I can't imagine using just 12V for two yellow motors and a third motor.

12 volts for a single motor is sufficient, but for two yellow motors, it might not be enough to provide optimal performance.
They will work very slowly

Indeed, you're right. If you plan to use lower voltages, is a bad choice. I'm currently using around 20 volts, and they don't heat up at all. However, when I receive more motors, I'll increase the voltage to 30 volts to see how they perform. For low-power projects, the mini version that supports 7/8 volts might be a better choice. It seems this module is designed to handle up to 35 volts

I suppose that using 12V with a 35V module is not the best solution, I imagine that for it to work well it is to use something close to 30 volts, never at the maximum but not at the minimum either

You have this code repeated three times.
Why?

Write one function that you supply with trigger and echo pin numbers, and which returns a range.

Serial.print("Distance1: ");
Serial.print("Distance2: ");
Serial.print("Distance3: ");
I think that is write individually for each sensor, although you could make a variable... But the way is not bad, it is good for a prototype since you can test the individual sensors more easily.

...until you find a cut-and-paste error repeated.

I honestly don't understand what he wants to do with this code.

For move 2 motors is easier, I also see that have an HC 5/6 Bluetooth adapter, he could use his mobile.

*We only need to create 2 sliders in the MIT App Inventor application for move the motor clockwise and counterclockwise...using any PWN pin with a maximum of 255 for the power limit.

I think he wants to make a car that moves by itself... but deflecting the obstacles with the sensors... the truth is that for this he would need a much more complex code.
To start moving 3 motors with 12 volts it would no longer be good.
It can be done but it's super slow, I also do not understand the arduino with an ESC motor control this is normally used with a radio control....the truth is that I do not understand very well what he wants to do

You're right
I wanted to make a car with obstacle avoidance that could also optionally be controlled via bluetooth
And about the code, I'm kinda new to building arduino based projects and just used a simple code to see if it works or not

It was running kinda slow actually so, I'm gonna increase the voltage of the battery pack

I wanted to use it for a vaccum mechanism.
Basically, wanted to make a DIY roomba

I just used a prototype code for it but
Thanks for the suggestion
Will implement in the project

Hi,
Look at NewPing Library to do your ultra sonics.
Much easier and you can implement more than one unit

Look in the examples that come with the library.

Tom... :smiley: :+1: :coffee: :australia:

Understood. Exactly, using 12 volts to power 3 motors is quite tight. I usually use 20 volts for 2 motors. When increasing the voltage, be very careful with the positive and negative battery connections. At 20 volts, it can be risky...a wrong connection or cables touching each other can cause them to start burning within seconds. For this project, perhaps 30 volts would be advisable, but if you don't have much experience with 20 volts, I suggest gradually increasing the power, try 15v, 18v, 21v, and so on, until you find a voltage that is sufficient for the device while also working with the project safely and easily.

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