Motor shield L298P

So basically i have a lipo battery, 2 dc motor, and one bluethooth module. Wanted to control the motor but somehow it failed. but when I plug in the arduino cable to the computer and also connect all the battery, motor, bluethooth module; it somehow can turn again. but it failed when i plug off the arduino cable from the computer. Any reason for this?

Hi, @kokomi001
Can you please post a schematic of your project?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, component names and pin labels.

Can you please post your code, using code tags?

Can you please post link to specs/data of the two motors.

How are you using the Lipo to power the Arduino?
What model Arduino are you using?

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

Are you using a single lipo battery to power up the whole circuit? Or 2 lipo batteries in series? One lipo is never sufficient to power up all the components that you have mentioned.

I uses Arduino Uno

CODE:
#include <SoftwareSerial.h>
char cha;
int PinDIrM1 = 12;
int M1 = 9;
int PinDIrM2 = 13;
int M2 = 8;
int M1spd = 10;
int M2spd = 11;
int spd= 255;
int spd2=0;

void setup() {
pinMode(PinDIrM1,OUTPUT);
pinMode(PinDIrM2,OUTPUT);
pinMode(M1,OUTPUT);
pinMode(M2,OUTPUT);
pinMode(M1spd, OUTPUT);
pinMode(M2spd, OUTPUT);
Serial.begin(9600);
}

void loop() {
if (Serial.available() > 0) {
cha = Serial.read();
Serial.print(cha);

  if (cha == 'F') {
    forward();
  } else if (cha == 'B') {
    backward();
  } else if (cha == 'L') {
    left();
  } else if (cha == 'R') {
    right();
  } else {
    Stop();
  }
}

}
void forward() {
digitalWrite(PinDIrM1,LOW);
digitalWrite(M1,HIGH);
analogWrite(M1spd, spd);
digitalWrite(PinDIrM2,HIGH);
digitalWrite(M2,LOW);
analogWrite(M2spd, spd);
}
void backward() {
digitalWrite(PinDIrM1,HIGH);
digitalWrite(M1,LOW);
analogWrite(M1spd, spd);
digitalWrite(PinDIrM2,LOW);
digitalWrite(M2,HIGH);
analogWrite(M2spd, spd);
}
void left() {
digitalWrite(PinDIrM1,LOW);
digitalWrite(M1,LOW);
analogWrite(M1spd, spd2);
digitalWrite(PinDIrM2,HIGH);
digitalWrite(M2,LOW);
analogWrite(M2spd, spd);
}
void right() {
digitalWrite(PinDIrM1,LOW);
digitalWrite(M1,HIGH);
analogWrite(M1spd, spd);
digitalWrite(PinDIrM2,LOW);
digitalWrite(M2,LOW);
analogWrite(M2spd, spd2);
}
void Stop() {
digitalWrite(PinDIrM1,LOW);
digitalWrite(M1,LOW);
analogWrite(M1spd, spd2);
digitalWrite(PinDIrM2,LOW);
digitalWrite(M2,LOW);
analogWrite(M2spd, spd2);
}

But before this issue happened , it could power up the both motor? After awhile it suddenly just stopped rotating.

is it because my lipo battery weaken?

Yes. Charge gone. How many volt is your lipo/lipo pack?

7.4V i think. But when I tried directly connect the dc motor to the lipo battery , it rotates quite fast and normal.

Another thing I wanted to mention is that usually the motor shield green & yellow led blinks when it wants to control/rotate the dc motor. but right now it don't blink unless I plug my arduino uno to the computer. Is this also my lipo battery problem?

Kindly charge your lipo pack fully and try again. The batteries must be fully charged. L298 draws a lot of current. It's very common to lose a lot of battery charge within a short time. Also check if there is any accidental short circuit occurring in your setup and draining your battery faster than usual.

Alright thanks for the advice.

Dont mind if i ask another question , my arduino uno board; the "L" orange Led keeping having turned on without off/blinking. Can't upload any sketch at the same time too.

Kindly disconnect your UNO from the other parts of your circuit. And check it separately. See if this behaviour persists when you try to connect your UNO to your computer with the USB cable.

Yeah I've already removed the whole circuit. Left the arduino board that's all. the issue still persist sadly

I even press the reset button, nothing blinks. It does not allow me to upload the "blink" sketch either.

Hi,

Do you have a DMM to measure your battery voltage?

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

I am afraid that the Arduino Board is gone. You'd better purchase a new one.

Hi,
I notice in your images you are using a UNO with the classic USB socket.
When plugging shields in, the metal top of the socket can contact any solder joints in the shield, shorting to gnd.

Place one or two layers of insulting tape over the socket so contact cannot be made.

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

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