# Modify circuit to turn motor on/off multiple times per switch press

I purchased a timed air freshener kit which makes the motor spin when the switch (SW1) is pressed. I have created a schematic based on the diagram in the instructions (pdf).

simulate this circuit – Schematic created using CircuitLab

At the moment the circuit will run the motor once per switch press. How would I modify the circuit to make the motor "turn on and off" multiple times per switch press?

Requirements:

• Continuous "on and off" motor cycles when switch is in ON state (currently the switch is a push button, thinking I should replace this with a toggle to make sure it is either ON or OFF)
• Motor should turn on for 1 second
• Motor should turn off for 5 minutes

If it's possible I would like to control both these periods using a variable resistor. R3 in the diagram is actually a variable resistor which controls the length of time the motor stays on for.

• Please define some parameters. How many times should it cycle? What is the time period for the off and on states? For example, when you press the button, do you want the motor to turn on for 1 second every 10 seconds, a total of 3 times? This is very different from turning on for 100ms every 1s a total of 100 times... – JYelton Aug 6 '13 at 19:50
• @JYelton I have added the requirements to my question. I am still learning so I would be interested in how I would calculate different scenarios. – xylar Aug 6 '13 at 20:04
• We're all learning. :) I'm just trying to help you provide some information that the gurus will want to know in order to point you in the right direction. (I'm not a guru.) – JYelton Aug 6 '13 at 20:05

## 2 Answers

This is very easy to do with a microcontroller. The tiny and cheap PIC 10F200 can do this easily.

The button is wired between ground and a processor pin that has a internal pullup. The button is then only a input to the processor. The processor does the timing and whatever other logic you want, then turns the motor on/off via another output.

There is no need for a darlington if the transistor will be driven from a processor pin. I expect the motor takes relatively little current, so something like the cheap and readily available 2N4401 can do this. Give the base about 1/50 of the worst case motor current, and the transistor will stay saturated when on. I'd add a reverse Schottky diode accross the motor to prevent turn-off spikes from damaging the transistor.

Olin gives the uC solution, which is really the best way to do things like this nowadays. If you are doing this stuff a lot, then learning the ropes with them is a must.

However, just in case you aren't savvy with micros, here is a simple circuit which can be adapted to your requirements. The period of the on/off is dictated by C1/R3 and C2/R4, you can use pots for R3/R4 to control the period of on/off. The main on/off is the switch S1 which controls the P-channel MOSFET M1. This can be replaced by another transistor or IC output if necessary. OUT goes to the motor control transistor/relay.

You can also implement this type of circuit with logic gates, and a "squarer" output is easily achieved (though as long as the output is high relative to the motor FET treshold it shouldn't make much difference if the output is slightly curved) Or a couple of opamps, or 555 timers...

EDIT - now you have given your timing specs, this circuit (as is) is not ideal for such a long period. However, it's relatively easy to adjust things to suit the longer periods (e.g. use FETs, opamp, gates, 555's, as mentioned) Let me know if you are interested in such a solution (what components/complexity you would prefer) and I'll post another circuit.

Simulation:

• Thanks for you answer. Think I will go with Olin's uC version. Interesting to compare the two methods and to see how you developed the original circuit. – xylar Aug 8 '13 at 6:30