There are a couple of issues with the proposed design:
- The 4n35 is an optocoupler, not a regular transistor. While the output side can conceptually be treated as a BJT, the maximum collector current rating for it is 100 mA, which may be insufficient for driving multiple motors, or even one motor, depending on the motor's current requirement.
- For the switching element, use a Bipolar Junction Transistor (BJT) such as the 2n2222 (800 mA maximum continuous collector current) or a logic-level MOSFET such as the IRLML2502 (3.4A @ 4.5 Vgs, at least 2 Amperes at 3.3 Vgs) instead. Depending on the motor current requirement, and the number of motors to be run, you may need a higher current rated BJT or MOSFET.
- The NetDuino IO pins output 3.3 Volts, with an absolute-maximum current rating of 25 mA per pin, 125 mA total. Even if the 4n35 is to be used for optical isolation, which is its purpose, adding an indicator LED in series with the input of the 4n35 is not a good plan, as the voltage drop for the LED (e.g. 2.2 to 3.4 Volts) will leave too little headroom for the 4n35 internal IR LED (~1.2 to 1.5 Volts).
- Using the LED in parallel with the input too isn't a good idea, since the current for the 4n35 (e.g. 20 mA) and for the LED (e.g. 10 mA) will add up as the load on the IO pin, thus loading the Netduino's GPIO pin beyond its rating.
- In other words, either drive your indicator LED from a separate GPIO pin, or move it to the output side.
A high-level solution, leaving you to work out the specifics:
simulate this circuit – Schematic created using CircuitLab
- (optional for isolation) Drive the 4n35 input from the GPIO pin with a series resistor to limit GPIO current to under 20 mA
- Use the output to drive a MOSFET (or use a BJT with appropriate biasing if desired)
- MOSFET (or BJT) as switch to power the motor(s).
Note that the motor will be on when the netduino output is low, and vice versa. The circuit can be reshuffled to eliminate this inverting of logic, if required.
Your motor that you linked to is a 4.5V 190~250 mA (No Load) motor. At 9v, the current probably increases. You are overdriving it by 200%. And any load/weight will cause it to increase in current requirements as well. Stall current is probably 10x that at least.
You are missing the protection diode across the motor, that can easily kill the transistor.
The Transistor you are using is a 100mA standard, 200mA Absolute Maximum. One of those motors by itself without any load, can easily kill that transistor.
The base resistor is calculated as (Base Voltage - Base-Emmiter Voltage) / Current required
. Base Voltage is the Arduino pin, so 5v, Vbe depends on the collector current which is 200 mA here, so typically 1V. Current required is calculated as Collector Current (200mA) / Hfe (From datasheet, 10~30). On the safe side, lets go with 10, so 200 / 10 = 20mA needed at the base.
(5V - 1V) / 20mA or 4V / 0.02A = 200Ω resistor. A 1kΩ resistor would only allow 4mA at the base, which times the Hfe of 10, would only allow 40mA at the collector, probably no where enough to tun on the motor.
TLDR: You need the protection diode, your 9v power source is too high, and your transistor is too weak for the motor you are using. And you need a bigger resistor at the base because the motor requires more current then you are figuring. A common 2n2222 transistor with a 470Ω resistor would do much better.
Edit: Not making the pin an output also puts a damper on things. Answer, Arduino pins default to input.
Best Answer
I believe the netduino IO to be 3V3 and this means the emitter of the transistor can never be higher than about 2.7V with any load connected. This is realistically the problem you have - the motor is only receiving about half of the 5V it needs and is therefore stalling. The led works because it only needs a couple of volts (more than likely).
You need to have the motor and diode (same way round as drawing shows) from the collector up to +5V. The emitter needs grounding and the input to the base (from the netduino) goes via a 1k resistor.