I connected the 12v power supply with 9v battery. The problem is that when i run 1 motor at time from any side (out 1, 2 out 3, 4) it works perfectly, but when I try to run both of them, only one will run and the other won't. They work if I run one motor at a time.
Is this a problem with not enough power? The motors are DC gear motors. This is the code:
int in1 = 12; int in2 = 13; int in3 = 8; int in4 = 9; int en1 = 11; int en2 = 10; void setup() { pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); pinMode(en1, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(en2, OUTPUT); } void loop() { analogWrite(en1, 255); digitalWrite(in1, LOW); digitalWrite(in2, HIGH); analogWrite(en2, 255); digitalWrite(in3, LOW); digitalWrite(in4, HIGH); }