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.
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.
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..
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.