Sorry if I'm posting this in the wrong place, redirect me elsewhere if need be.
I'm using transistors as a switch to power my motors when supplied with a base current from the arduino. I need to turn two motors independently and I'm using two transistors, one for each motor. This almost works perfectly. However, when a base current is supplied to one transistor, both motors are turning instead of one. It seems to be something to do with both collector-emitter currents coming from the same power source as, when I use two separate battery packs, it works perfectly. However I'd much prefer to use one battery pack for both motors and still have them control independently.
I'll give my code just in case it helps, but I'm pretty sure it's an electronic's issue, not a software issue. I can update this post with a circuit diagram later, if need be.
void setup() {
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
digitalWrite(10, HIGH);
Serial.println("9HI");
delay(1000);
digitalWrite(10, LOW);
Serial.println("9LO");
delay(1000);
digitalWrite(9, HIGH);
Serial.println("10HI");
delay(1000);
digitalWrite(9, LOW);
Serial.println("10LO");
delay(1000);
}
If you can link an answer to a similar question, that would also be very helpful.