Hi all! This is my first forum post, so I apologize for any lack of decorum my post has. Feel free to correct any errors you see .(actual problem statement is below my code, if you want to skip the background) I have done some work with Arduino before, and made some basic inventions (like a machine that stirs your coffee), but I do not have a ton of experience with circuitry, and have never been formally trained. I am trying to make a quadcopter using normal DC motors, not the ridiculously overpriced ones on Amazon, and I have tried many different approaches with motor drivers, but they are usually too heavy or need too much power or something else. I decided to make my own drivers with this tutorial:
I used 2N2222 NPN transistors, 270 ohm resistors, a 3.7v lipo battery, and 1N4001 flyback diodes. The motors I got are here: https://www.amazon.com/USAQ-Coreless-Brushed-8-5x20mm-Propeller/dp/B06Y11C2HL/ref=sr_1_6?dchild=1&keywords=4+small+dc+motor+with+propeller&qid=1609860121&sr=8-6
I have attached a png file of my circuit diagram, and my code is below:
void setup() {
// put your setup code here, to run once:
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(9,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(3,100);
analogWrite(5,100);
analogWrite(6,100);
analogWrite(9,100);
}
The problem is, whenever I run this code, the motors on pin 3 and pin 6 don't run (they spin very slowly at higher speeds) while the other two motors spin quickly. I have switched motors out, changed out transistors, checked wiring, and looked for others with this problem. I found someone with a similar problem, and it was decided that he was exceeding the draw current limits of the 2N2222 transistor. I have looked at the datasheet for this transistor, and I made a point of ordering motors with specs that would not overwhelm it. (specs can be found on the amazon link above). I also made a copy of the circuit on the Tinkercad circuit simulator, and all of the motors ran at the same speed with no problem. (they tell you the RPM) Any help or advice would be appreciated, and feel free to double check check my work. Thanks for reading this really long entry!