# 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!

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.

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 a SCHEMATIC were needed even if it is hand drawn
• 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!

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

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;
decode_results output;
void setup()
{
Serial.begin(9600);
//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() {
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);
}
}
}

(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

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..

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

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;
decode_results output;
void setup()
{
Â  Serial.begin(9600);
Â  //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() {
Â  Â  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);