L298n needs arduino to be connected to pc

Hi Good Day. I am working on a bluetooth car then after my dog wrestled on it I had to repair it. One of the problems I got was that I could not run my motor without connecting it to the usb connected to the computer. 2x 18650 batteries are supposed to be powering the arduino and l298n, it worked before it broke. I did some troubleshooting with the code then I realized the motors were running if the arduino is connected via usb but when I unplugged it, both the arduino and l298n are on but the motors are not working. I have done this with and without bluetooth control. Please, I would like to know what is wrong.

int enA = 5;
int in1 = 7;
int in2 = 8;
int character;

void setup() {
  // put your setup code here, to run once:
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
if(Serial.available()>0){
  character=Serial.read();
  
}
if(character == '7'){
analogWrite(enA, 255);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
}
else{
  analogWrite(enA, 255);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
delay(10);
}

Did it work before the dog attach? If so, connect the things the same way.
Telling about various more or less random attempts brings no clarity to the situation.
A wiring diagram is needed for fault finding.

Thanks for your reply. Everything is the same. The code for the whole bluetooth car is different(longer and a lot of unnecessary stuff for this issue).

All wiring is the same. I think the problem is the vin pin, because I power it via the vin pin. When I power it using the usb cable, it works.:grinning:

I guess that You are the wrestling dog.
Post a wiring diagram. I have my suspicions...

Will it be ok if it's hand drawn?

Yes.

Hi,
Do you have a DMM?

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

What is DMM?:sweat_smile::sweat_smile:

Type "DMM" in the Google search bar.
Select images.

Processing: 20210724_170458.jpg...

I don't have a digital multimeter but I borrowed it before from a friend.

once I had a similar problem. It turned out that the ground-connection was bad.
As long as I tested the circuit with the USB-cable plugged in the ground-connection was given on a "hidden path" as follows:

ground of arduino-board----shielding of USB-cable-----shielding-of-laptop----protective-conductor-of-power-supply---230V-socket--------another socket-protection-wire-of--oscilloscope plugged in------ground of oscilloscope-probe----GND of-motor-board

Man I was astonished to find out that! All this was caused by a cold soldering joint who looked like GND is connected directly from GND-motor-board to Arduino-GND but turned out to be interrupted.

So all in all is your GND-connection between all parts working?
best regards Stefan

I can't really tell. I tried to power it using a 9v battery via the vin, but still it did not work. When I power it via the vin pin the power, tx, and 13 LED are brightly lit in the board, which is a bit confusing about the tx being lit up without the board sending datas.

So you solved your problem because there was a loose ground connection right? By the way were you able to see the picture I sent for the schematics?

no the post with the text
Processing: 20210724_170458.jpg...

changes the mouse-arrow to a hand indicating "this is a link" but nothing happens if I click on it.
You can simply copy & paste pictures directly into a posting

best regards Stefan

Hi,
Please read the post at the start of any forum , entitled "How to use this Forum".

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

How can I do that on android?:grinning:

You seem to like this famous game of ping-pong-postings always too short to be clear what they want to say

So my too short posting is

"what?"

I am currently using android and I used that file upload beside the code upload. It seems like I can't upload any images here on android. I will just log in, in my computer to upload my schematics.

I hope you can see it now.