How to wire a DPDT Switch to a Motor
Occassionally all you need to do is a wire a motor to a switch. If you wire it to a normal switch that doesn't allow you to flip the direction. To flip direction you need something to switch both the negative and positive sides. This type of dual switch is called a double pole double throw switch (DPDT). Wiring it up in the schematic shown on the right allows you to make a motor spin forward and back.
If you are controlling something that you need to have stop when a start or end is reached you need to add normally closed switches (NC Switch). These switches create a connection when not pressed and open the connection when pressed. By wiring a motor, a DPDT switch, two NC switches in the diagram shown on the right the motor will go forward and back and stop when either end is reached.
If you use normally open switches then the motors will move only when the endstop buttons are pressed.