I'm struggling with a little project of mine. It's pretty simple, I've got a motor with it's own battery source and I'm shorting that circuit using a TIP31.
What seems to happen though is the motor is drawing power from the Arduino causing it to reset?!
After a bit of research I introduced an optocoupler I had laying around which triggers the TIP31 however the completed circuit seems to run a lot slower than if I short circuited it by hand.
How can I complete this circuit without a loss of current or screwing up my arduino?
The "motor" is actually a battery powered sprayer that I've hijacked the micro-switch -/+.
In short the Opto is a 4N28
I have a 330 Ohms working with the 4n28
TIP 31 is the transistor
Arduino mega is the MCU
Pin 1 (opto) goes to Arduino digital 13 via a 330 Ohm resistor
Pin 2 (opto) goes to arduino ground.
Pin 5 (opto) goes to Switch+
Pin 4 (Opto) goes to TIP31 Base
Tip 31 Collector goes to Switch+
Tip 31 Base goes to Pin 4 (Opto)
Tip 31 Emitter goes to Switch-
[edit] Bit more detail. The sprayer is powered by 2 x AA batteries. Arduino via USB
Yes, its called a pen. Draw it on a piece of paper and post a photo of it.
If you are going to switch a motor with two AA batteries then you only have 3V, A transistor will "cost you" up to 1.3V, depending on the current you draw. Therefore you only have 1.7V to power your motor. This would explain why you see some difference between the transistor switching on and you shorting out the collector / emitter.
You might be better off using a FET, but with only 3V to play with you might have trouble finding one that switches with such a low voltage.