Objective:
To control the rotation direction and to stop/start the DC motor by Arduino Uno
Components Required
- Arduino Uno
- Direct Current (DC) Motor
Connection Diagram
Program
int MotorPin1=4, MotorPin2=5;
void setup()
{
pinMode(MotorPin1, OUTPUT);
pinMode(MotorPin2, OUTPUT);
}
void loop()
{
digitalWrite(MotorPin1,HIGH);
digitalWrite(MotorPin3,LOW);
delay(5000);
digitalWrite(MotorPin1,LOW);
digitalWrite(MotorPin3,HIGH);
delay(5000);
}
Working
The DC motor has two terminals. To make it run we must supply a HIGH voltage to one terminal and the LOW voltage to the other terminal. The current flowing from HIGH voltage to LOW voltage through the armature of the coil. It produces Electro-Magnetic field and deflects with the permanent magnets inside the DC motor there by rotating in one direction. If we change the polarity of DC motor terminals it starts to rotate in opposite direction. To make it stop supply both terminals of the DC motor to same voltage (Both HIGH / Both LOW)
Output
DC motor starts to rotate in alternate directions.