DC motor beeping

I have a 2 DC geared motor at 6V connected to a l298n with a power supply of 9V problem is the first motor is rotating but the second is not and when i lower the speed to 50, the second motor beeps while the first is working just fine here is my code:

int enA = 10;
int enB = 5;
int sp = 255;
void setup(){
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
}

void loop(){
   digitalWrite(9, HIGH);
  digitalWrite(8, LOW);
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  analogWrite(enA, sp);
  analogWrite(enB, sp);
  delay(3000);
  digitalWrite(9, LOW);
  digitalWrite(8, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  analogWrite(enA, sp);
  analogWrite(enB, sp);
  delay(800);
}

Hello Devon,

Just a quick question, is that 9 Volt supply a battery?

Sincerely yours,

Mike

yes it's a battery

I have a 2 DC geared motor at 6V connected to a l298n with a power supply of 9V battery problem is the first motor is rotating but the second is not and when i lower the speed to 50, the second motor beeps while the first is working just fine, here is my code:

int enA = 10;
int enB = 5;
int sp = 255;
void setup(){
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
}

void loop(){
   digitalWrite(9, HIGH);
  digitalWrite(8, LOW);
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  analogWrite(enA, sp);
  analogWrite(enB, sp);
  delay(3000);
  digitalWrite(9, LOW);
  digitalWrite(8, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  analogWrite(enA, sp);
  analogWrite(enB, sp);
  delay(800);
}

A 9 Volt battery has a capacity of 400 - 500 mAh, but before that value is reached the Voltage already drops quite allot, causing problems very often. Try a different power supply or use 2 batteries in parallel before looking at your code. Maybe, if you have one, you could show us a schematic?

Sincerely yours,

Mike

Mikeb1970:
A 9 Volt battery has a capacity of 400 - 500 mAh, but before that value is reached the Voltage already drops quite allot, causing problems very often. Try a different power supply or use 2 batteries in parallel before looking at your code. Maybe, if you have one, you could show us a schematic?

Sincerely yours,

Mike

It was working fine before until i took it apart then put it back at the same pins.

In that case Devon, maybe you made an error putting it back together? Anyway, you should still consider a better 9v supply, I am sure all other posters will agree with me.

Yours,

Mike

Mikeb1970:
In that case Devon, maybe you made an error putting it back together? Anyway, you should still consider a better 9v supply, I am sure all other posters will agree with me.

Yours,

Mike

I think I made an error but I troubleshooted this thing in every way I can think off, what I tried so far
-Switching the two motors, both worked fine when connected to enA
-Switching pins in arduino, no luck on this one
-Switching pins in l298n, no luck on this either
all resulted on enB not working

When I read 9v battery and motors together, I shudder.

The 9v battery that is used in smoke detectors is not a good choice for driving motors. It simply cannot provide the needed current.

Try again using AA batteries.

vinceherman:
When I read 9v battery and motors together, I shudder.

The 9v battery that is used in smoke detectors is not a good choice for driving motors. It simply cannot provide the needed current.

Try again using AA batteries.

It was working fine before till' i disassembled it then put it back where it was before.
Regardless of that how many AA batteries do I need to use and how many Volts?

@devon19, do not cross-post. Other thread removed.

sorry bout that, i didn't know how to delete

Devon,

Do you have a multimeter or even better an oscilloscope? Try measuring the output going to the B side of your driver, if that's ok measure the output going to the engine, there must be some voltage there, since your engine is beeping. It's difficult to help you from so far away.

Mike

Thank you Mike for the help but I guess I'll quit on this one and let my groupmates handle this matter. Thank you again for the help much appreciated

devon19:
It was working fine before till' i disassembled it then put it back where it was before.

That is new information to me. Why did you not mention it in the first post?

Regardless of that how many AA batteries do I need to use and how many Volts?

6 AA batteries will give about 9v, which is in the same range as your smoke detector battery.
After the (largish) voltage drop that the l298n has, this leaves about 6v for your 6v motor.

DON'T CROSS POST!!!!!!!!!!!!!!!!!!!!

I HAVE REPORTED THIS THREAD TO THE MODERATORS

Threads merged.