Change the PNP transistor to an NPN, connect the emitter to ground, base same as before, and collector to the -ve side of the LED, 5V to the +ve side.
As RasPiSteve says, the base-emitter voltage determines whether the transistor is on or off; with your arrangement it'll always be on.
A word of caution; check that your laser diode is happy with just a 5V supply, and no current limiting. Most (non-laser) diodes need a series resistor, as they are constant-voltage devices. Also check that the current draw isn't too much for your transistor or the Pi supply; check the diode data sheet.
As RasPiSteve says, the base-emitter voltage determines whether the transistor is on or off; with your arrangement it'll always be on.
A word of caution; check that your laser diode is happy with just a 5V supply, and no current limiting. Most (non-laser) diodes need a series resistor, as they are constant-voltage devices. Also check that the current draw isn't too much for your transistor or the Pi supply; check the diode data sheet.
Statistics: Posted by jayben — Mon Jul 08, 2024 8:30 am