The intention is that the strip will gradually go from dim to full brightness. However all I get is a flash at the start, and then the LEDs stay off for the rest of the loop. What am I doing wrong?
The problem may lay here. Are there really 300 LEDs? If so, what are you using to power them? The code is allowing for 2.5W of total power (5V * 0.5A) . For 300 LEDs that allows just 8.3mW per LED. A typical 5050 LED can draw 60mA at full intensity and run at 0.21W. For 300 LEDs , that's 63W in total which at 5V would draw 12.6 amps. If your power supply is capable of only 500mA as suggested by the code, then that's not going to cut it.
That was just purely copied from a tutorial I found on YT. I don't really understand voltages/power etc, nor know what the LEDs consume so I have no idea what the correct setting should be
I've just been trying different things as the strip just arrived today. Have cut it down to the first 10 leds and it gives a much better range of brightness. Will I be able to power this from mains?
That said, my original code still had the same problem so clearly had a syntax problem too.
I don't want to be "picky" but the board in the video is a Nano and you are using an ESP32 and there is a crucial difference between in that the Nano is a 5V device whilst the ESP32 is a 3.3V device
Having said that, the Nano cannot safely supply enough current for 60 LEDs so it is just as well that in the video only 12 are used
Do you see some major differences between the project in the video and your project ?
It's 3.3 from the ESP32 as you said. I have also tried it with a 9V battery which gave better brightness as expected. Not sure whether to try connect mains or whether I'd kill the strip and/or myself.
DO NOT CONNECT TO THE MAINS! For example, typical household strip lights require 12V DC supplied by a suitable PSU. The LEDs are not arranged in series but in groups to allow them to be driven from whatever DC voltage they are designed for.
The mains adapter will be providing whatever voltage it is designed for. Let's ay that it is 5V, such as a common USB supply Connect the GND of the power supply to the LED GND and the EPS32 GND and the power supply 5V to the LED positive and the 5V pin of the ESP32. Connect the ESP32 LED pin (18) to the LED data in pin
The ESP will be powered at 5V
The LEDs will be powered at 5V but not via the ESP32 so you can use as many LEDs as you like provided that the power supply can supply enough current
The LED data signal will be at 3.3V but will still control the LEDs and the current required is tiny
See this is what's confusing me about electronics. It seems that current is the limiting factor, but batteries, the ESP output, the rating on the strip, all refer to the voltage.
By the way, there was no power supply supplied with the strip.
Do you understand the difference between current and voltage and the relationship between them ?
The specification that you posted shows that the LEDs work at 5V. That means that if you supply them with much less voltage, say 1V, then they will not work but will not be damaged. However, if you supply them with much more voltage, say 24V then not only will they not work but you are very likely to damage them permanently. In practice you should aim to supply them with around 5V but it does not have to be exact
Given the 5V, each LED requires a certain amount to current to make it light up. Each of the LED packages in a WS2812 actually has 3 LEDs in it. One each red, green and blue. If you turn all of them on fully then they will take the required current, and produce white(ish) light.
The voltage is applied equally to each LED in each of the LED packages on the strip. They are connected in parallel and share the voltage. Current, however, passes through each LED in series so if one LED package requires say 100mA to light all of its 3 LEDs fully, then when you want to light up 2 packages fully you need to supply 200 mA, 3 packages 300mA and so on
The main reason for quoting only the voltage and not the current in the specification that you posted, apart from laziness on the part of the supplier, is to differentiate between LED strips that run at different voltages. Remember, if you supply excess voltage then the LEDs can be damaged. In contrast, you cannot supply too much current because the LEDs will only use what they need and if you cannot supply enough current they don't work, or at least not as expected, but won't be damaged, as you have discovered