Connecting DC motor

Hello,
I am just starting to work with arduino and I am really interested in DC motors(I have basic knowledge of electronics). For my first project I want to connect dc motor and make its speed controllable. I made a scheme, but want to ask:

  1. Do I need any additional diode somewhere?(I saw someone using it in paralleled to motor and didn't understand what for)

  2. Why do I need a resistor(saw it in others' schemes)?

DovydasR:
Hello,
I am just starting to work with arduino and I am really interested in DC motors(I have basic knowledge of electronics). For my first project I want to connect dc motor and make its speed controllable. I made a scheme, but want to ask:

  1. Do I need any additional diode somewhere?(I saw someone using it in paralleled to motor and didn't understand what for)

  2. Why do I need a resistor(saw it in others' schemes)?

https://drive.google.com/file/d/1LP4GA4x7L3U02RMhbL8IWOrhzPbAX0HC/view

The diode is to prevent damage to the device that is driving the motor from the high fevers voltage generated when the motor is turned off and the magnetic fields inside the motor collapse. You can't power a motor from an Arduino output pin. You need a driver that is controlled by the Arduino. For controlling a motor's speed that rotates in only one direction, a MOSFET controlled by PWM is probably the most efficient way. For forward and reverse with speed control, a H-bridge controller is needed. The choice of either driver depends on the rated voltage of the motor and the motor stall current specifications.

from the high fevers voltage

He meant to say reverse voltage. :wink: ([u]Back-EMF[/u])

...If you connect a motor to a battery "by hand" with wires sometimes you'll see a spark and that's the high-voltage back-EMF. And, sometimes it will give you a little shock if you're touching the wires.