Laser works when connected to 5v and 3.3v pins, but not an output pin

I'm fairly new to all of this, can't figure out why this won't work. It's a green 5mW laser diode on an Uno board. Works flawlessly when connected directly to 5v or 3.3v + ground, but will not turn on when connected to any of the output pins. The code is correct and I've tested other LED's and whatnot on the same pins. I was under the impression that all of the output pins were also 5v current, is that not the case?

Did you set the pinMode to OUTPUT?

If you want more help, post your code and a wiring diagram.

output pins were also 5v current, is that not the case?

5V and recommended max current of 20mA. How much current does the laser need. You will need a driver if it needs more than 20mA.

I even tried testing it with the most simple code/wiring possible.

The laser diode only has a power and ground wire. Power to pin 12, ground to GND. Other stuff like LEDs work fine using this exact setup on the same pin. The laser works fine when plugged directly into the 5v or 3.3v pins. I'm really at a loss, it seems like it should work :frowning:
I'm unsure of the current draw on the laser. Is the 20mA maximum for the output pins only?

const int laser = 12;

void setup() {

pinMode(laser, OUTPUT);

}

void loop() {

digitalWrite(laser, HIGH);
delay(50);
digitalWrite(laser, LOW);
delay(50);
}

Do you have a data sheet for the laser? How much current does the laser need? Like I said, an output can provide only limited current. If the laser draws too much current, the voltage drops and the output pin can be damaged.

darkshark9:
The laser diode only has a power and ground wire....
I'm unsure of the current draw on the laser.

Easy enough to measure: just break the circuit and stick your ammeter in there...

It's a green 5mW laser diode on an Uno board.

Draws too much current for an output pin. You will damage the output pin if you continue. Or, you may already have damaged the pin. You will need a transistor switch. Some examples shown below.

jremington:
[5mW] Draws too much current for an output pin.

?

P=VI and I=P/V

5mW/5V = 1mA.....

meltDown:
?

P=VI and I=P/V

5mW/5V = 1mA.....

The 5mw refers to the emitted power (or should), but how much input current goes as heat (LED and frequency doubler)?

The 5mw refers to the emitted power

Yes. Current draw of a 5 mW green laser diode is much higher than the absolute maximum of an output pin.

This 5mW example draws up to 300 mA.