Using Two Modules

Hi, I would like to use two (2) L298 Motor Modules for my project. Does anyone have any idea how? I currently have an idea but it seems to not do anything. Any ideas are appreciated. Thanks! :smiley:

That's not much to go on. It's certainly possible to use two L298 motor drivers so I'd say you've probably done something wrong.

Please show us what you have tried...a circuit diagram/schematic and the code you used. Include details of exactly what "L298 motor modules" you have, what motors you are trying to drive and what you are using to power everything.

Steve

@sioty

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.

Posting tips.

  • Always list the version of the IDE you are using and the board version if applicable.
  • How to insert an image into your post. ( Thanks Robin2 )
  • Add your sketch where applicable but please use CODE TAGS ( </> )
  • Add a SCHEMATIC were needed even if it is hand drawn
  • Add working links to any specific hardware as needed (NOT links to similar items)
  • Guessing is not the best way to describe an issue. Actual facts are the most important.
  • Remember that the people trying to help cannot see your problem so give as much information as you can

slipstick:
That's not much to go on. It's certainly possible to use two L298 motor drivers so I'd say you've probably done something wrong.

Please show us what you have tried...a circuit diagram/schematic and the code you used. Include details of exactly what "L298 motor modules" you have, what motors you are trying to drive and what you are using to power everything.

Steve

Tell me if it's wrong and what changes I should do. If it's correct then tell me also, I might deja vu or imagined that it was wrong. Thanks! :grinning:

I made an attachment for the picture of my breadboard schematics (sorry if it's kinda confusing)...
And the code I used is:

#include <IRremote.h>

#define forward 6375
#define backward 19125
#define left 4335
#define right 23205
#define stop_button 14535
#define rag_button 0xFF42BD
#define scrubber_button 0xFF52AD

int IN_1 = 12;
int IN_2 = 11;
int IN_3 = 10;
int IN_4 = 9;

int IN_1_1 = 7;
int IN_2_2 = 6;
int IN_3_3 = 5;
int IN_4_4 = 4;

int OnOrOFF = {0,0,0,0,0,0,0,0,0,0};

char command;
int receiver_pin = 2;
IRrecv receiver(receiver_pin); //Arduino will take output of IR receiver from pin 2
decode_results output;
void setup()
{
Serial.begin(9600);
receiver.enableIRIn(); // Start to take the output from IR receiver
//initializing all the pins as output pins
pinMode(IN_1, OUTPUT);
pinMode(IN_2, OUTPUT);
pinMode(IN_3, OUTPUT);
pinMode(IN_4, OUTPUT);
pinMode(IN_1_1, OUTPUT);
pinMode(IN_2_2, OUTPUT);
pinMode(IN_3_3, OUTPUT);
pinMode(IN_4_4, OUTPUT);

}
void loop() {
if (receiver.decode(&output)) {
unsigned int value = output.value;
switch(value) {

case forward:
//Moving Forward
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
break;

case backward:
//Moving backward
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
break;

case left:
//Turning left
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
break;

case right:
//Turning Right
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
break;

case stop_button:
//Stop
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, LOW);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, LOW);
break;

if(rag_button == 1){
digitalWrite(IN_1_1, HIGH);
}else{
digitalWrite(IN_1_1, LOW);
delay(500);
}

if(scrubber_button == 1){
digitalWrite(IN_3_3, HIGH);
}else{
digitalWrite(IN_3_3, LOW);
delay(500);

}
Serial.println(value);
receiver.resume();
}
}
}

(mod edit)

LOL you used a TABLE instead of CODE TAGS ( </> )

Code tags allow people to select and copy the code to check it out on thier own computers.

The biggest issue I see is that you seems to be a missing ground.

That can cause some odd issues all by itself.

Bob.

You don't seem to have anything connected to the ENA, ENB pins and as Bob says you have no ground connection between the Arduino and the motor drivers.

Plus 4 x AA cells is not enough to drive 4 motors via L298s which can drop 2.5-4V themselves leaving you only about 2-3V to run the motors.

Steve

ballscrewbob:
LOL you used a TABLE instead of CODE TAGS ( </> )

Code tags allow people to select and copy the code to check it out on thier own computers.

The biggest issue I see is that you seems to be a missing ground.

That can cause some odd issues all by itself.

Bob.

Thanks Bob! And got it, use CODE TAGS :sweat_smile:

slipstick:
You don't seem to have anything connected to the ENA, ENB pins and as Bob says you have no ground connection between the Arduino and the motor drivers.

Plus 4 x AA cells is not enough to drive 4 motors via L298s which can drop 2.5-4V themselves leaving you only about 2-3V to run the motors.

Steve

If I change it so that the 4 x AA cells powers the Arduino and the 2 x 18650 cells power both the two L298s, will that be enough?

Please be careful mixing power supplies.
Especially current aspects.

There are occasions when you can supplement PSU's with other PSU's
However I do recommend you learn about the topic a bit first.

sioty:
If I change it so that the 4 x AA cells powers the Arduino and the 2 x 18650 cells power both the two L298s, will that be enough?

No. 6V isn't enough for the Arduino. 7.4V might be a bit better for the L298s but the simplest approach is to leave the 18650s where they are and add a couple of cells to the AA pack to make 6 cells (9V) for the drivers.

Steve

Hi,
Do you know if your project is receiving the IR signal?
Have you got code that JUST receives and confirms IR operation, without any motor code at all?
Have you got code that JUST operates the motors, without any IR code?

Thanks.. Tom.. :slight_smile:

HI,
Look in your code and look for the } that closes the switch …case function.
It should be after the last break; command, yours has no } after the last break;

I have hopefully put a } in the right place, and using TOOLS, AUTO FORMAT tidied your code so it has detents to make it easier to read.

#include <IRremote.h>


#define forward 6375
#define backward 19125
#define left  4335
#define right  23205
#define stop_button  14535
#define rag_button 0xFF42BD
#define scrubber_button 0xFF52AD


int IN_1 = 12;
int IN_2 = 11;
int IN_3 = 10;
int IN_4 = 9;


int IN_1_1 = 7;
int IN_2_2 = 6;
int IN_3_3 = 5;
int IN_4_4 = 4;


int OnOrOFF[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};


char command;
int receiver_pin = 2;
IRrecv receiver(receiver_pin); //Arduino will take output of IR receiver from pin 2
decode_results output;
void setup()
{
  Serial.begin(9600);
  receiver.enableIRIn();  // Start to take the output from IR receiver
  //initializing all the pins as output pins
  pinMode(IN_1, OUTPUT);
  pinMode(IN_2, OUTPUT);
  pinMode(IN_3, OUTPUT);
  pinMode(IN_4, OUTPUT);
  pinMode(IN_1_1, OUTPUT);
  pinMode(IN_2_2, OUTPUT);
  pinMode(IN_3_3, OUTPUT);
  pinMode(IN_4_4, OUTPUT);


}
void loop() {
  if (receiver.decode(&output)) {
    unsigned int value = output.value;
    switch (value) {


      case forward:
        //Moving Forward
        digitalWrite(IN_1, LOW);
        digitalWrite(IN_2, HIGH);
        digitalWrite(IN_3, HIGH);
        digitalWrite(IN_4, LOW);
        break;


      case backward:
        //Moving backward
        digitalWrite(IN_1, HIGH);
        digitalWrite(IN_2, LOW);
        digitalWrite(IN_3, LOW);
        digitalWrite(IN_4, HIGH);
        break;


      case left:
        //Turning left
        digitalWrite(IN_3, HIGH);
        digitalWrite(IN_4, LOW);
        break;


      case right:
        //Turning Right
        digitalWrite(IN_1, LOW);
        digitalWrite(IN_2, HIGH);
        break;


      case stop_button:
        //Stop
        digitalWrite(IN_1, LOW);
        digitalWrite(IN_2, LOW);
        digitalWrite(IN_3, LOW);
        digitalWrite(IN_4, LOW);
        break;
    }
    if (rag_button == 1) {
      digitalWrite(IN_1_1, HIGH);
    } else {
      digitalWrite(IN_1_1, LOW);
      delay(500);
    }




    if (scrubber_button == 1) {
      digitalWrite(IN_3_3, HIGH);
    } else {
      digitalWrite(IN_3_3, LOW);
      delay(500);




    }
    Serial.println(value);
    receiver.resume();
  }
}

Tom… :slight_smile:

Hi,
If you are using 2 x Lipo 18650 batteries, check the 5V pin on the UNO to make sure you have 5V.
When using the DC socket as you are, you need at least 7V to make sure the onboard linear reguator can deliver 5V.

Tom.. :slight_smile: