How to Control Motor With SPDT Relays
by Chaitanya Sanghadia in Circuits > Arduino
11595 Views, 104 Favorites, 0 Comments
How to Control Motor With SPDT Relays

This will tell you how to make a DC motor go clock and counterclockwise
Downloads
Parts
![20160110_103541[1].jpg](/proxy/?url=https://content.instructables.com/FSO/HP4O/IJ7WST29/FSOHP4OIJ7WST29.jpg&filename=20160110_103541[1].jpg)
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
Connect the Relays to the Breadboard
![20160103_141404[1].jpg](/proxy/?url=https://content.instructables.com/FUB/DSDJ/IIYUP8IA/FUBDSDJIIYUP8IA.jpg&filename=20160103_141404[1].jpg)
![20160103_142725[1].jpg](/proxy/?url=https://content.instructables.com/FE5/7A5X/IIYUPJD0/FE57A5XIIYUPJD0.jpg&filename=20160103_142725[1].jpg)
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
Connect NC to NC and NO to NO
![20160103_143740[1].jpg](/proxy/?url=https://content.instructables.com/FIL/WNN1/IIYUPQUY/FILWNN1IIYUPQUY.jpg&filename=20160103_143740[1].jpg)
This will connect the two relays together.
Connect a Transistor
![20160103_144321[1].jpg](/proxy/?url=https://content.instructables.com/FLG/6DI2/IIYUPU35/FLG6DI2IIYUPU35.jpg&filename=20160103_144321[1].jpg)
![20160103_144736[1].jpg](/proxy/?url=https://content.instructables.com/FQD/8NLS/IIYUPW62/FQD8NLSIIYUPW62.jpg&filename=20160103_144736[1].jpg)
The transistor has 3 pins: Collector, Base, and Emitter. Connect it so that the hump is facing away from the wiring we already did.
Now Make the Connections
![20160103_145819[1].jpg](/proxy/?url=https://content.instructables.com/FKB/QGPA/IIYUQ4XY/FKBQGPAIIYUQ4XY.jpg&filename=20160103_145819[1].jpg)
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).
Add the Diode
![20160103_150300[1].jpg](/proxy/?url=https://content.instructables.com/F8K/W4ZW/IIYUQ90D/F8KW4ZWIIYUQ90D.jpg&filename=20160103_150300[1].jpg)
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.
Do Steps 4-6 for the Other Relay
More Wiring
![20160103_152516[1].jpg](/proxy/?url=https://content.instructables.com/F41/NSNI/IIYUQTWY/F41NSNIIIYUQTWY.jpg&filename=20160103_152516[1].jpg)
Connect a wire from the pin that the grey side of the diode is facing and connect that to 5V for both relays
Connect the Ardino
![20160110_102942[1].jpg](/proxy/?url=https://content.instructables.com/FFC/NTN0/IJ7WSP44/FFCNTN0IJ7WSP44.jpg&filename=20160110_102942[1].jpg)
![20160110_103157[1].jpg](/proxy/?url=https://content.instructables.com/FTJ/WPLF/IJ7WSQC5/FTJWPLFIJ7WSQC5.jpg&filename=20160110_103157[1].jpg)
Connect a wire to the other side of the resistor and connect that to pin 8 and 9 on the arduino
Connect the Two Commons to the DC Motor
![20160103_154450[1].jpg](/proxy/?url=https://content.instructables.com/FDJ/4QZ7/IIYUR52P/FDJ4QZ7IIYUR52P.jpg&filename=20160103_154450[1].jpg)
And also put something on top of the motor, so you know which direction its spinning
Add Power
![20160103_155045[1].jpg](/proxy/?url=https://content.instructables.com/FZP/UJ5L/IIYUR7V9/FZPUJ5LIIYUR7V9.jpg&filename=20160103_155045[1].jpg)
connect 3-5v power supply (Like a battery). I used a regulated power supply.
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);
}