Voltage on digital output pins depending on voltage source?

Hello everyone. This is my first post on the forum. I’m an experienced computer / PLC programmer, but my experience with microcontrollers and my understanding of electronics is rather limited.

I’m working on a project with the Fastled library and I’m controlling a Neopixel string over a digital output pin. The leds are 12V powered with a 5V control signal (WS2815). The sketch I made was working flawless on an Arduino Uno on pin 6. I now switched to an Arduino Nano 33 IOT and when using 12V (same as the ledstrip) on the Vin pin the leds are not lighting up in the correct way. I presume the 12V is converted to 3.3V on the output pin and that is what is causing the issue.

However, if I power the Nano 33 iot over the usb interface then the control signal to the LED’s is working spotless. Does this mean that when connected to the USB power source the output pins are supplied with the full 5V from the USB?

If the above is correct, then I would be happy to receive some suggestion how I could power the Arduino from the 12V DC power supply while being able to control the LED’s.

Welcome to the forum

The supply voltage for the SAMD21 microcontroller on the Arduino Nano 33 IoT is regulated to 3.3V (that is what the 33 in the name comes from).

The output HIGH signal for a digital pin will always be slightly lower than the supply voltage (Vcc). The output low voltage will be zero volt.
For input the voltage will be a range (check datasheet for exact values). For instance LOW signal will be detected from 0V to 0.3Vcc (0.99V) and HIGH signal will be from 0.55Vcc(1.8V) to 3.3V. Input voltages from 1V to 1.8V are forbidden because the result (LOW or HIGH) is unpredictable. These factors a different for every device (see datasheet I/O Pin Characteristics).

The same is true for a 5V device. The range will be different. Now when you connect a 3.3V device to a 5V device there are 4 cases.

5V device LOW (0V) to 3.3V device (0V) -> OK
3.3V device LOW (0V) to 5V device (0V) -> OK
5V device HIGH (5V) to 3.3V device (max 3.3V) -> damages the 3.3V device
3V device HIGH (3.3V) to 5V device (min 3.5V) -> signal too low, sometimes it works sometimes it will not

To solve this, you need a level shifter or logic level converter. The exact solution depends on the application. You can build one using a transistor because you have only one pin and one direction. You can also simply get a little module (even from Amazon) that can have multiple channels and both directions. This would be used if you have a bus e.g., SPI or I2C or little motor controller ...

nikic:
Does this mean that when connected to the USB power source the output pins are supplied with the full 5V from the USB?

Nope. You are just lucky in one case. The voltage conversion from 5V to 3.3V and from 12V result in slightly different supply voltages and ripple.