I currently have an Arduino UNO connected to a L298N which is then connected to 2 motors. Problem is, only one motor spins at a time, and when it does it is very easy to make it stop by holding it with a hand, and when you let go it doesn't start to spin again. You need to give it a spin with your hand to make it start rotating again.
I think the main problem for this, is the power supply. I had 4 1.5V cells connected in series in a cell holder which outputs 6V, which I connected to the L298N and took the 5V+ output and attached it to the 5V pin on the Arduino board. This made me think that the motors weren't getting enough power so I made the 6V go only to the L298N module and had a seperate 9V battery for the Arduino board. Turns out, it didn't really make a difference.
So, is 6V too low for two motors? These are the motors by the way. I'm really starting out in electronics so any help would be appreciated!
Here's the code:
// motor one
int enA = 10;
int in1 = 9;
int in2 = 8;
// motor two
int enB = 5;
int in3 = 7;
int in4 = 6;
void setup() {
// put your setup code here, to run once:
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// Motor A
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, 255);
//Motor B
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
analogWrite(enB, 255);
}