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

Step 1: 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

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

This will connect the two relays together.

Step 4: 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

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

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

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

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

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

Step 11: 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);


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



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??
<p>You can use an external power supply for the DC motors.</p>
<p>Great motor controller tutorial.</p>

About This Instructable




More by Chaitanya Sanghadia:PS3 controlled Robotic Arm PS3 controlled Nomad 4 wheel drive truck How to control motor with SPDT relays 
Add instructable to: