Motor controlled by 3-way switch

Hello,
I am making an aerial tramway model powered by a DC motor. The motor is hooked up with the DRV8833 motor controller chip (like this) and an Arduino Uno board. I am reusing this setup from last quarter's school project PiBot, if anyone has heard of it.

Now I want to install an on-off-on switch (like this one) so that I can control the direction of the motor with a flip of the switch.
My question is: How can I wire them up? Do I need to program the microprocessor?

I originally somehow overlooked the motor driver, and posted solutions without it, so removed the posts.

Instead, this is one way of doing it:-

If you're simply using a switch to change direction, no programming is needed.

If you wanted to control speed as well, or even both speed and direction using the Arduino, a different circuit is needed, but it's still easily achieved.

Thank you for your reply!

Yes, I do want to control the speed using the Arduino (assuming that the direction is already taken care of by the switch?). How do I connect the pins of the switch to the circuit? What confuses me is how the Arduino can "sense" the position of the switch and change the direction of the motor accordingly.

midnight_puppy_2303:
Thank you for your reply!

Yes, I do want to control the speed using the Arduino (assuming that the direction is already taken care of by the switch?). How do I connect the pins of the switch to the circuit? What confuses me is how the Arduino can "sense" the position of the switch and change the direction of the motor accordingly.

I did say, "If you wanted to control speed as well, or even both speed and direction using the Arduino, a different circuit is needed"

All you need is to enable the internal pullup resistor on your 'direction' pin, and then have the switch connected between your 'direction' pin and ground. You only need one pair of the multiple contacts on the switch. (A SPST switch is all you really need.)

Then, when the 'direction' pin is high, you turn the motor in one direction, when it's low, you turn the motor in the opposite direction. Too easy. :slight_smile:

For speed control: a N-channel MOSFET between the bottom relay COM and GND, with a PWM signal to the gate.

CrossRoads:
For speed control: a N-channel MOSFET between the bottom relay COM and GND, with a PWM signal to the gate.

That's actually a switch diagram.

The diagram in in one of the posts that I deleted, (when I noticed he's using a ready-made driver), had both speed/power and direction control. I used it with an ATtiny in a watch-winder last week. Since I went to the trouble of modifying it for this thread:-

Edit: I only used the MOSFET for power on/off, but it could also easily control speed with PWM.

Excellent. Be sure to use a logic level MOSFET, such as AOI514:

CrossRoads:
Excellent. Be sure to use a logic level MOSFET, such as AOI514:
http://www.digikey.com/product-search/en?keywords=aoi514

In my circuit, I used a 2SK2231, (because I have heaps sitting here). It was only a low-current motor, so I wasn’t too concerned about the ‘on’ resistance.
It was for someone else, and he reports it’s working great.

(And it sort of was super-slow 20% d-c PWM - 5 min ‘on’, 20 min ‘off’. ) :smiley:
Edit: Alternating direction for each 5 min ‘on’ period.