This is the only way I was able to control (turn on/off) my green laser module with my Arduino board. I made the same mistake other people have made connecting the laser module directly to the board, which, for some reason does not work.
I am using:
One NPN-type transistor called a TIP120.
One 5mw green laser module
My Arduino Uno board
My code:
const int transistorPin = 9; // connected to the base of the transistor
void setup() {
// set the transistor pin as output:
pinMode(transistorPin, OUTPUT);
}
void loop() {
digitalWrite(transistorPin, HIGH);
delay(500);
digitalWrite(transistorPin, LOW);
delay(15000);
}
If you see something wrong with my schema please let me know...
Off the top of my head I don't know the pinout for the TIP120 but assuming you have the transistor in correctly you should have a resistor from the Arduino to the base (no resistor is shown). Collector to the laser and emitter to GND.
Also, how much current does the laser draw? Maybe the Arduino regulator is objecting.
About the resistor, where exactly do I have to put it? From pin 9 to Ground? From Base to ground? Between pin 9 and Base? Sorry I ask but I am new to electronics.
To limit current flow to the base of the transistor, as it has low resistance.
h(fe) = 1000, for this transistor.
I(c) = 300 mA in your case, than base current has to be more than:
300 / 1000 = 0.3 mA
By Ohm law, R = V / I ;
so, R = ( 5 V (pin 9) - 2.5 (base emitter tip120) ) / 0.3 mA = 8.33 kOhm ;
Resistor should be less than 8.33 kOhm, anything in range 1 to 8 kOhm is o'key.
There is a ambiguity, on picture they install IRF510 or IRF520 MOSFET,
as you can see marking "FET" on the body of the transistor.
And FET doesn't require resistor, as no DC current.
It bad practice, IMHO resistor has to be any way, to limit
charging gate-source capacitor current.
On low frequencies arduino will survive such mistreatment at least.
But in description to the picture:
"Connect the base to an output pin of the microcontroller, and the emitter to ground like so: "
That is WRONG.,
If transistor is MOSFET, description must be:
"Connect the GATE to an output pin of the microcontroller, and the SOURCE to ground like so: "
if transistor TIP120, you already know what to do -):