Controlling DC motor speeds with Arduino and giving equal power.

vortix

Well-Known Member
So im switching to a smaller build and I tried to control the speed of a tiny DC motor that I happen to own. I used a transistor and it works but there is an issue. The motor speed is much weaker than connecting it directly to the battery. I have a 3.7v battery and if I connect the motor to a transistor and than arduino, it would be the same max speed as connecting it to a transistor and than to Arduino 5v. Both however, are much weaker than hooking it up to 3.7v directly. So how do I control the speed of the motor using Arduino without making its max speed weaker? I want to give it the same power that it gets from the battery with the ability to control its speed through Arduino.
 
What transistor are you using and how are you wiring it? Also what's the motor control portion of the code look like? You probably want to use a transistor to avoid burning out the arduino. The trick is to use the correct transistor and signal from the arduino. TIP120s are pretty versatile for this.
 
C:
int potValue=0;
int anlg=A2;
void setup(){
  Serial.begin(9600);
  pinMode(5,OUTPUT);
   pinMode(3,OUTPUT);
  }

void loop(){

    potValue = analogRead(anlg);
    potValue = map(potValue, 0, 1023, 0, 255);
         Serial.println(potValue);
         analogWrite(5,potValue);
          analogWrite(3,potValue);
       }

Any higher than 255 and the motor turns off.

not sure about transistor since I had a box with a bunch of stuff in it But it says "2N 2550 819" On it. Not sure if that's helpful.

When I connect it to the Arduino:

left Transistor pin goes to ground, middle goes to Digital pin and right goes to Ground of motor, Motor power goes to Arduino 5V .

when I connect it to a battery and Arduino :

left Transistor pin goes to ground, middle goes to Digital pin and right goes to Ground of motor, Motor power Goes to battery, Battery ground goes to Arduino ground.

Some detail like the battery Being 1000Mha is not accurate but that's how I generally wired it.
 

Attachments

  • Batt.jpg
    Batt.jpg
    796.5 KB · Views: 1
  • NoBatt.jpg
    NoBatt.jpg
    715.1 KB · Views: 1
Last edited:
Back
Top