About the L293D Motor Driver Shield need help please

I gonna to use the link shown idea to diy a GPS car, the link used L293D Motor Driver Shield to drive 4 motors, my question is how can I use it without a L293D Motor Driver Shield , and directly hook a L298 New Dual H Bridge to drive two motors and still use the sketch from the link to do the project?

link for GPS car:

link for L293D Motor Driver Shield:

link for L298 New Dual H Bridge:

may I us the pin below to hook my driver which from .cpp?

// enable both H bridges
    pinMode(11, OUTPUT);
    pinMode(3, OUTPUT);
    digitalWrite(11, HIGH);
    digitalWrite(3, HIGH);
      // enable both H bridges
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);

You can use whatever pins you want to connect to that driver. You do not get an PWM using that board versus the adafruit shield. You will have to do that yourself.

1 Like

The thing if I like to use his code, I got need make sure what pin relative to the pin IN1-4 on L293 board,

I plugged the L293D shield into a MEGA2560, searched out that the Adafruit_MotorShield.CPP found:

if (dcmotors[num].motornum == 0) {
    // not init'd yet!
    dcmotors[num].motornum = num;
    dcmotors[num].MC = this;
    uint8_t pwm, in1, in2;
    if (num == 0) {
      pwm = 8;
      in2 = 9;
      in1 = 10;
    } else if (num == 1) {
      pwm = 13;
      in2 = 12;
      in1 = 11;
    } else if (num == 2) {
      pwm = 2;
      in2 = 3;
      in1 = 4;
    } else if (num == 3) {
      pwm = 7;
      in2 = 6;
      in1 = 5;
    dcmotors[num].PWMpin = pwm;
    dcmotors[num].IN1pin = in1;
dcmotors[num].IN2pin = in2;

the DC motor's physical wiring pin address, I tried to directly operate the pins like this:

const uint8_t  ENABLE_A = 8;   
const uint8_t  MOTOR_A1 = 9;   
const uint8_t  MOTOR_A2 = 10;   

// Define pins for Motor B
const uint8_t  ENABLE_B = 13;   
const uint8_t  MOTOR_B1 = 11;   
const uint8_t  MOTOR_B2 = 12;   

int motorSpeedA = 200;  
int motorSpeedB = 200; 

void setup() {

  Serial.begin(115200); //

  // put your setup code here, to run once:
  pinMode(MOTOR_A1, OUTPUT);
  pinMode(MOTOR_A2, OUTPUT);
  pinMode(MOTOR_B1, OUTPUT);
  pinMode(MOTOR_B2, OUTPUT);

  pinMode(ENABLE_A, OUTPUT);
  pinMode(ENABLE_B, OUTPUT);
  digitalWrite(ENABLE_A, HIGH);
  digitalWrite(ENABLE_B, HIGH);


void loop() {


  //  analogWrite(ENABLE_A, motorSpeedA);
  //  analogWrite(ENABLE_B, motorSpeedB);
    digitalWrite(MOTOR_A1, LOW);
    digitalWrite(MOTOR_A2, HIGH);
    digitalWrite(MOTOR_B1, LOW);
    digitalWrite(MOTOR_B2, HIGH);


/////D2  FORWARD:


 //   analogWrite(ENABLE_A, motorSpeedA);
  //  analogWrite(ENABLE_B, motorSpeedB);
    digitalWrite(MOTOR_A1, HIGH);
    digitalWrite(MOTOR_A2, LOW);
    digitalWrite(MOTOR_B1, HIGH);
    digitalWrite(MOTOR_B2, LOW);

the motor doesn't run, why?
Is it possibly to do this way? the example from Adafruit_MotorShield library works fine.

Then why not just use that as the basis for controlling your motor?

1 Like

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