Can you use an NPN transistor to control a 3.3v curcuit with a 5V control signal?

I have a Sparkfun RGB rotary encoder that I’m hooking up to an Arudino Nano. The blue and green LEDs run at 3.3v. The red led runs at 2. I figured I could run the LEDs directly off of the 3.3v line.

Since the LEDs are common anode, I need to switch them on by raising a control pin on the Nano. Basically this would mean I’m using a 5V signal pin hooked to the base of the transistor to control a 3.3V circuit. All the examples I’ve seen do the opposite. They’ll use the lower voltage circuit to control the higher voltage one. Will it work in the other direction?

LEDs always require a current limiting resistor. I suggest you read this Sparkfun tutorial: https://learn.sparkfun.com/tutorials/li … iodes-leds.

You can connect the LEDs directly to the Nano without a transistor. For the 3.3V LEDs, use a 180ohm resistor in series with the LED. For the 2V LED, use a 330ohm resistor in series with the LED.

Will it work in the other direction?

Yes, you can apply any positive voltage (greater than 0.7V and within reason) to the base of an NPN transistor, as long as the base resistor is chosen to limit the base current to a safe value. For that safe value, see the transistor data sheet.