# Controlling motor direction, usage and speed

I want to build a machine that can follow a set of simple rules by which it controls a motor. These rules are yet to decided, but the patterns are as follows:

1. Turn motor clockwise for A minutes, then pause for B minutes and then continue in a anti-clockwise direction for C minutes (and repeat from beginning after a wait of D minutes)
2. Turn motor clockwise for A minutes and then pause for B minutes (and repeat from beginning)
3. Turn motor anti-clockwise for A minutes and then pause for B minutes (and repeat from beginning)

Now, I might simplify things and decide not to include a switch between patterns and only use pattern 1, but let's include the option to have the user input which pattern should be executed.

I plan to use a low RPM motor, something similar to this 6 RPM motor. Moreover, could the speed of the motor be adjusted (for example, 1-6 RPM) as well? How?

With my lacking knowledge of microcontrollers, how could these features be achieved? Do I need relays for the motor as well? How about the speed settings? I suppose I could have a dial with a few preprogrammed pattern and speed settings.

-
Afters om additiona research I am warmng for the idea to use a Arduino, EasyDriver and a stepper motor. Something like this: youtube.com/watch?v=SCyGM2Tp37w Does it sound like a good idea? Considering that I could program it quite freely and accurately. Any disadvantages? For example having it running four days on end? –  Figaro Jun 7 '14 at 19:20

You could achieve your goal combining a microcontroller with an H-bridge.

An H-bridge is a circuit that lets you control a motor, making it spin in both directions depending on commands given by a microcontroller. Here's an example of an H-Bridge built with BJTs.

You will then need to program your microcontroller with the exact pattern that you want, following the pseudo-code that you laid out in your question. If you are new to microcontrollers as you mentioned, I suggest you get started with an Arduino.

I hope this helps.

-
Arduino has been popping up in the searches today and I finally got around to read what it is all about: looks really interesting! So, in order to get going in the right direction, a Adurino Uno, an external power supply and a H-Bridge are what I need? Anything more? How about the speed control, can the Arduino do this as well? What kind of motor accepts variable speed? –  Figaro Jun 7 '14 at 17:23
I guess that's what you need. Maybe there are a few other details to sort out. Speed control can be achieved by pulsing a PWM signal into the ENABLE pins of the H-bridge I mentioned. What happens is that the PWM signal turns the motor on and off very quickly (at around 10's of kHz). You can control how much of the time the motor is on, controlling speed effectively all the way up to full speed. –  Ricardo Jun 7 '14 at 19:53