Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I have an Arduino Digital Out pin connected to a 1k resistor, then connected the base of a 2N3904 transitor. In fact, that same digital out is connected to several resistor->base-of-2n3904. Each transistor is in turn driving a p-channel mosfet.

I would like to add a pushbutton to override the digital out. By that, I mean that the digital out is most of the time OFF, but sometimes ON from a brief moment. Pressing the pushbutton will have the same effect as turning ON the digital out.

I don't think I can simply add a momentary pushbutton between the digital out and +5V, can I ? This will probably feed 5V directly into the output pin. Should I maybe add a resistor in series with the pushbutton ? do I risk frying the pin by adding the pushbutton like so:

schematic

simulate this circuit – Schematic created using CircuitLab

share|improve this question
2  
A BJT like 2N3904 has a base not a gate. –  jippie Mar 24 at 18:30
    
You can safely add a push button from the transistor's collector to ground. –  jippie Mar 24 at 18:34
    
I would put a resistor between the Arduino output pin and the pushbutton/R1/R2/R3 junction, and omit R5 –  Peter Bennett Mar 24 at 18:37
    
@OlinLathrop Maybe I am misreading the text, but the push button across the transistor C-E does have the same effect as the one drawn in the circuit (when disregarding the controller output). –  jippie Mar 24 at 19:02
    
@Jippie: Opps, I didn't notice that you said collector to ground. –  Olin Lathrop Mar 24 at 19:20

5 Answers 5

up vote 4 down vote accepted

You could switch this around and make the output of the Arduino open-drain, tied to +5 through a 10K resistor (R4). Get rid of the three transistors, and drive the gates of the MOSFETs directly from the output pin. (By the way, I'm not sure why you have three transistors in parallel; it seems you could of run the output of one transistor to all thee MOSFETs.)

Now, setting the output pin to ground will be the same as turning on the transistors in your earlier circuit (collectors connected to ground). Setting the pin high (tri-stated for open-drain outputs) will leave the outputs at +5 due to R4. Meanwhile, if the switch is now connected to ground, and tied directly to the outputs (no R5), pushing the switch will also drive the output low without interfering with the output pin of the Arduino whether it is tro-stated or at at ground.

enter image description here

If you want to use your existing circuit, making as few changes as possible, you should be able to isolate the switch and the output of Arduino using just a 1N4148 diode and adding a resistor to ground. (The resistor in series with the switch is removed.)

enter image description here

share|improve this answer
    
Thanks, this seems much cleaner. My problem is that part of this system is already built and being used, the resistor-transistor-mosfet circuits are actually each on separate boards with other components. But from the answers, I get the feel that I should perhaps redesign the whole system. –  Etienne D. Mar 24 at 20:27
    
@EtienneD If you want to use your existing circuit, making as few changes as possible, you should be able to isolate the switch and the output of Arduino using just a 1N4148 diode. See above. –  tcrosley Mar 24 at 21:33
    
A diode solves everything –  Passerby Mar 24 at 23:19

This is what I was thinking out loud in the comments.

schematic

simulate this circuit – Schematic created using CircuitLab

The push button can be in parallel to the BJT without a problem.

share|improve this answer
    
But that would be the equivalent of activating just one of the transistors, not all of them. –  Dave Tweed Mar 24 at 19:54
    
This would work, but I was looking for a single pushbutton to trigger every BJT, this is what I attempted to describe as 'overriding the digital out'. –  Etienne D. Mar 24 at 20:18

The digital output presumably drives actively both in the high and low directions. 10 kΩ to any voltage from 0-5 volts won't have any effect on it.

There is a way to do this. Connect the bottom of R5 directly to the base of Q1, which means on the right side or R1. I'd also make R1 higher. The collector load is only 10 kΩ, so 10 kΩ on the base is plenty low enough. R5 of 10 kΩ as you have it now should then work.

Remember that the digital output will be actively driving the left side of R1 low during the pushbutton override. With R1 and R5 equal, most of the current thru R5 will go to turn on the resistor since the base will be at about 700 mV. If R1 were much lower than R5, as you have it now, then most of the current thru R5 during override will actually go thru R1 and into the digital input instead of into the base of Q1.

However, a better way to do this overall is to connect the button to another input of the processor, then perform the override action in firmware. That way the firmware knows it's happening, the switch will be debounced, and you don't have to worry about current sharing. The only real drawback is that it takes another input pin. As long as you have one available, this is really the better way to solve the problem.

share|improve this answer

I'm not sure if jippie had something like this in mind, but you can use a "master" transistor that will control the rest of the transistors.

The transistor I have used is in an emitter follower configuration (to avoid inversion). When the AVR output is high then the emitter will output about 4.3v and will turn the output transistors on. If the button is pressed during that state then it will just feed the output transistors with 5v which will not make a difference for the way they are used (as switches).

When the AVR output is low then the transistor will be off, but the button will be able to override and feed the output transistors with 5v.

schematic

simulate this circuit – Schematic created using CircuitLab

share|improve this answer

You could use a SPDT momentary pushbutton (or momentary toggle)

schematic

simulate this circuit – Schematic created using CircuitLab

Probably the simplest way for an existing system.

Or if you must use a momentary SPST, one added diode and resistor will make it happen.

(But @tcrosley already posted the second solution, so look at his answer!).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.