Add pushbutton to motor with transistor switch

Hello!
I tried this set up from http://www.me.umn.edu/courses/me2011/arduino/technotes/motorswitchled/

I would like to add a switch to this design so that I could trigger the motor by either sending signal to pin 4 or pushing an external button. Is it possible? Could you show me how?

Just take another wire from the base (B) of the transistor to 5V through a switch. Then either the pin or the switch will excite the base and turn the transistor on.

JimboZA:
Just take another wire from the base (B) of the transistor to 5V through a switch. Then either the pin or the switch will excite the base and turn the transistor on.

Could you show me a schematic? I'm sorry

Should it look like this

or this?

I can't comment on the second one but I'm pretty sure the first one would work. Remember if you use an i/o pin, to set it high.... or just use 5v power pin.

Thank you! +1 karma

@JimboZA, the second one is just hardware debounce. But he would need to add a diode to pin 9 to prevent feedback and possibly hurt the arduino.

HazardsMind:
@JimboZA, the second one is just hardware debounce. But he would need to add a diode to pin 9 to prevent feedback and possibly hurt the arduino.

Ah, right...

ArduinoTime you better take the karma back- my suggestion would be putting 5v on pin 9 as well as on the transistor, and that's not wise since it would be set as an output...

HazardsMind:
But he would need to add a diode to pin 9 to prevent feedback and possibly hurt the arduino.

a regulator diode? like 1N4001?

JimboZA:
ArduinoTime you better take the karma back- my suggestion would be putting 5v on pin 9 as well as on the transistor, and that's not wise since it would be set as an output...

I don't think I can take it back? You could just help me with this one.. :smiley:
If I want to use the pushbutton for trigger so that I could tell the transistor to open for a certain time what should I add to the circuit?

Have a look at the Blink Without Delay example here or in the IDE examples, and also ButtonStateChange.

EDIT... I'm at work now (730am here....) but I'll have a proper look at that tonight if you don't sort it before then. I owe you that for almost frying your board.

Just put a forward facing diode between R1 and the join where the other input connects from the switch.

That will stop the + going back into the Arduino.

Sorry can't supply schematic.

So: Pin 9, R2, diode (anode to R2) join from switch, etc.

@lost_and_confused, like this?

Try again, this time make it so the button can reach the transistor base pin.

@HazardsMind, where should the cathode face?

The transistor base, but before the Node.

Pin9-> resistor-> diode-> button node-> transistor base.

@HazardsMind, Thank you! :slight_smile:

If I want to use the pushbutton for trigger so that I could tell the transistor to open for a certain time

Have a look at this thread- a few different ways to implement that kind of thing.