USB laser switch

Laser switch circuit

A Waveshare RP2040-Zero running CircuitPython switches a small 5 V line laser on and off. The laser is powered from the board’s USB 5 V. An NPN transistor switches the laser’s ground connection, and the board drives the transistor from pin GP2.

Parts

Ref Part Notes
U1 Waveshare RP2040-Zero Powered and controlled over USB-C
Q1 2N3904 or PN2222A NPN transistor, TO-92 Good to about 100 mA of laser current; see “Laser current” below. The carrier board expects E-B-C pin order
R1 1 kΩ, 1/4 W axial resistor Base resistor, GP2 to Q1 base. Use 470 Ω if the laser draws 50–100 mA
R2 10 kΩ, 1/4 W axial resistor Pull-down, Q1 base to GND. Keeps the laser off during boot and reset
L1 5 V line laser module Must have its own driver board (see below)

Schematic

U1 5V ────────────────────── L1 +  (red)
                             L1 −  (black)
                                │
                                C
U1 GP2 ──[ R1 1kΩ ]──┬───── B  Q1 (NPN)
                     │          E
                  [R2 10kΩ]     │
                     │          │
U1 GND ──────────────┴──────────┘

Connections

From To
U1 5V L1 +
L1 − Q1 collector
U1 GP2 R1
R1 (other end) Q1 base, R2
R2 (other end) GND
Q1 emitter GND

Design notes

Firmware interface

code/code.py reads commands from the USB serial console (115200 baud), one per line: on, off, toggle, status, help. The front NeoPixel shows the state: dim green means the laser is off, red means it is on.