Arduino simple connection to DC motor

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
erik2019
 
Posts: 29
Joined: Tue Aug 21, 2018 1:30 am

Arduino simple connection to DC motor

Post by erik2019 »

I like to turn on and off an DV motor. But I can't get it to work. If I plugg motor to 3V and GND the motor spins. But when I do the same with a controlled pin, it do not work.

Code: Select all

const int pwm = A2 ; 

void setup() {
  pinMode(pwm, OUTPUT);
}

void loop() {
  analogWrite(pwm, 255);
}
motor2.png
motor2.png (407.14 KiB) Viewed 54 times

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: Arduino simple connection to DC motor

Post by dastels »

The motor is almost certainly requires more current that the digital pin can provide. Probably an order of magnitude more. So you'll need a transistor to drive the motor. Also inductive loads require a shunt diode to protect the driver.

See https://learn.adafruit.com/adafruit-ard ... -dc-motors.

Dave

User avatar
erik2019
 
Posts: 29
Joined: Tue Aug 21, 2018 1:30 am

Re: Arduino simple connection to DC motor

Post by erik2019 »

Super, I will test it! Thanks!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”