Things You'll Need
Instructions
Wire the positive terminal of your power source to pin 1 on the first relay. Pin 1 is usually a small metal screw on the corner of the relay with a 1 next to it. Then wire pin 2 of this first relay to one of the motor's terminals, which looks like a small metal screw on the motor's housing.
Wire the motor's other terminal to pin 1 on the second relay. Then wire pin 2 on the second relay to the negative terminal of the power source. This completes a circuit that will drive the motor forward. For future reference, the relays used in steps 1 and 2 will be referred to as relays 1 and 2.
Construct a second circuit identical to the one outlined in steps 1 and 2 using the third and fourth relays, except switch the wires connecting the positive and negative terminals of the power source. This will create a second circuit that drives the motor in reverse.
Wire pin 4 on each of the relays to the same ground the microcontroller uses.
Connect pin 3 on each of the relays to different output pins on the microcontroller. Note which relay connects to which output.
Program the microcontroller to turn on relays 1 and 2, wait one second, turn off relays 1 and 2 then turn on relays 3 and 4. This will drive the motor forward for one second, then reverse.