Introduction: How to Control Motor With SPDT Relays

Picture of How to Control Motor With SPDT Relays

This will tell you how to make a DC motor go clock and counterclockwise

Step 1: Parts

Picture of Parts

1. 2 SPDT (Single pole Double throw) relays

2. 2 1K resistors

4. 2 diodes

5. 2 Transistors (NPN)

6. Wires (all male ends)

7. Arduino UNO

8. Small DC motor

9. 1 Breadboard

Step 2: Connect the Relays to the Breadboard

Picture of Connect the Relays to the Breadboard

Connect both SPDT relays to the breadboard. Note of the pin facing, it will be important in later steps.

NO and NC refers to Normally Connected and Normally Open pins.

COM refers to the Common pin

Step 3: Connect NC to NC and NO to NO

Picture of Connect NC to NC and NO to NO

This will connect the two relays together.

Step 4: Connect a Transistor

Picture of Connect a Transistor

The transistor has 3 pins: Collector, Base, and Emitter. Connect it so that the hump is facing away from the wiring we already did.

Step 5: Now Make the Connections

Picture of Now Make the Connections

Connect the B pin on the transistor to one end of a resistor ( The other will go to the arduino). Next connect the E pin to ground. After that connect the C pin to one of the ends of the coils (the 2 pins next to the common) of the relay (DO NOT CONNECT TO THE COMMON).

Step 6: Add the Diode

Picture of Add the Diode

Put the diode at both coil pins ( one pin of the diode goes to the one connected to the C pin of the transistor.). Make sure that the grey band is facing away from the transistor.

Step 7: Do Steps 4-6 for the Other Relay

Step 8: More Wiring

Picture of More Wiring

Connect a wire from the pin that the grey side of the diode is facing and connect that to 5V for both relays

Step 9: Connect the Ardino

Picture of Connect the Ardino

Connect a wire to the other side of the resistor and connect that to pin 8 and 9 on the arduino

Step 10: Connect the Two Commons to the DC Motor

Picture of Connect the Two Commons to the DC Motor

And also put something on top of the motor, so you know which direction its spinning

Step 11: Add Power

Picture of Add Power

connect 3-5v power supply (Like a battery). I used a regulated power supply.

Step 12: Download This Code to Make This Work

I just modified the blink LED program.

// constants won't change. Used here to set a pin number :
const int R1 = 8; // the number of the LED pin const int R2 = 9; // the number of the LED pin

// Variables will change : int ledState = LOW; // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time // The value will quickly become too large for an int to store unsigned long previousMillis = 0; // will store last time LED was updated

// constants won't change : const long interval = 1000; // interval at which to blink (milliseconds)

void setup() { // set the digital pin as output: pinMode(R1, OUTPUT); pinMode(R2, OUTPUT); }

void loop() {

digitalWrite(R1, HIGH); digitalWrite(R2, LOW);

delay(3000);

digitalWrite(R1, LOW); digitalWrite(R2, HIGH);

delay(3000);

}

Comments

Alok Shaw (author)2016-01-05

i am using arduino adafruit motor control shield for controlling 4 12v dc motors....but i am confused about the power supply for the motor shield as i read on the manual of adafruit fruit that 9v supply will not work(why no idea)!! what sort of power supply other than lipo can i supply??

You can use an external power supply for the DC motors.

DIY Hacks and How Tos (author)2016-01-03

Great motor controller tutorial.

About This Instructable

6,654views

95favorites

License:

Add instructable to: