How to Spin a DC Motor with the Arduino

Update:08 Apr 2020
Summary:

The DC motor in your Arduino kit is the most basic of e […]

The DC motor in your Arduino kit is the most basic of electric motors and is used in all types of hobby electronics. When current is passed through, it spins continuously in one direction until the current stops. Unless specifically marked with a + or -, DC motors have no polarity, meaning that you can swap the two wires over to reverse the direction of the motor
To power the motor, you need to send 5V through it and then on to ground. This voltage spins the motor, but you have control of it. To give your Arduino control of the motor’s power, and therefore its rotation, you place a transistor just after the motor.
The transistor is an electrically operated switch that can be activated by your Arduino’s digital pins. In this example it is controlled by pin 9 on your Arduino, in the same way as an LED except that the transistor allows you the turn the motor circuit on and off.
This circuit works, but it still allows the chance of creating a reverse current because of the momentum of the motor as it slows down, or because the motor could be turned. If reverse current is generated, it travels from the negative side of the motor and tries to find the easiest route to ground.

This route may be through the transistor or through the Arduino. You can’t know for sure what will happen, so you need to provide a way to control this excess current.motor for air conditional suppliers

To be safe, you place a diode across the motor. The diode faces toward the source of the voltage, meaning that the voltage is forced through the motor, which is what you want. If current is generated in the opposite direction, it is now be blocked from flowing into the Arduino.