How To Program WS2812 LEDs with FastLED and an Arduino
Vložit
- čas přidán 21. 08. 2024
- In this video, I explain how to write your own programs that interact with WS2812B LED's using the FastLED library. I go over both preset colour schemes, and how to create your own colours using both RGB values or HSV values, and send them over to the LEDs.
IMPORTANT:
This video is part 2 of 2 of my Introduction to Addressable LEDs series. Part 1 focuses on setting up the hardware and software, and running some demos to get up and running.
Watch part 1 on Peertube:
peertube.tonyt...
Watch part 1 on CZcams:
• Get Started Using WS28...
Components used:
- Generic WS2812B 30 LED/m strip
- Generic Arduino Uno with Atmel 328p
- FastLED library
I won't add any links for purchasing, this video is not sponsored and all components were supplied by myself, but make sure you choose a reputable source for parts!
Links:
Arduino: www.arduino.cc
FastLED: fastled.io
Supported LEDs: github.com/Fas...
Code/issues: github.com/Fas...
Timestamps:
Coming soon.
Music:
Approaching Nirvana:
approachingnir...
open.spotify.c...
/ approachingnirvana
Song: Bangers and Smashed (Lapse in Time)
If there are any mistakes or bad practices I mentioned in the video, please leave a comment and I'll try to pin a compilation of updates.
Production rants/remarks:
- I know the 2 mics I used have different EQ's, it's really hard for me to match it, so I won't.
- I had to color correct all the camera shots, sry if I forgot anything.
Watch this video on Peertube:
peertube.tonyt...
Thanks for Watching!
Produced by Tony Tascioglu
tonytascioglu.com
As a guy who just want to do a specific project, that was just the perfect video that I was looking for.
Quick question... How to fade in/out the 2 leds that moving in the strip?
Thank you!! Keep your good work!
Sorry for the late response, since the whole strip is represented as an array, if you want to fade in/out before 'moving' to the next LEDs, then you can just loop and change the brightness of those 2 LED's directly in the array. If you want to fade in/out previous and next LEDs, in your loop, you can add a += and -= to the i+1 and i-1th LEDs to fade the next and previous LEDs in each cycle of the loop.
Wow so nice... Can make a vedio on random color choosing ws2812b
You should just be able to modify the code I showed to call the pseudo-random number generator and assign random RGB values to all the LEDs. If you want full brightness, just with varying colour, use the HSV format, max the saturation and value, and use the random number generator for the hue field. You should be able to run that in a for loop to set a colour for all the LEDs, though I'm not sure if the Arduino can generate random numbers that fast.
Here is the documentation for the random function: www.arduino.cc/reference/en/language/functions/random-numbers/random/
You can pass a min of 0 and max of 255 and use it to set the hue of each pixel.
HI, will this work with any led light strip manufacturer..not sure what mine is
Hello Tony, thanks for the video, which was very informative as I am creating a map project that gets info from an external computer, and I need to indicate 110 locations on a map with addressable LED`s run by an Arduino Uno. so my question is, would I have to tell the Arduino which map location refers to which piece of serial data? For example, would i need to put 110 different serial codes into Arduino memory to select whatever LED it refers to? Thanks from Russell.
If the 110 LED's are daisy chained together, you would just have an array with the 110 data elements in it. If you're updating it from an external computer, you can send the full data, or, as you mentioned, send just the elements you want to update - depends on your software implementation, either is possible!
How can i control 72 leds if I only want the 64leds in the middle to do rainbow running and the 4 front leds and 4 end leds to blink red and blue?
Plz tell me in which language the code is written ??
Thanks for sharing, it would be great if you do another tutorial on more random effects, that was fun watching and learning about effects, Also, is the FastLED library in Arduino IDE something like a Java Script behind Html for example,
Thanks
hat. wear it. good video.
Hi... Can arduino nano support 15 meter of ws2812b that's 900 leds
You're going to have issues with both the power and data for that many LEDs on the Nano, BUT, it IS possible with a more powerful microcontroller.
Power:
I doubt you'd be able to power 900 LEDs off a single power supply, let alone the Arduino directly.
The WS2812B LEDs are a bit picky about power and won't function below a certain voltage (or act glitchy).
Due to the resistance of the thin copper in the strip, you'll probably need to splice in power connections every few meters and feed it off a powerful 5V PSU.
But, given a PSU (like the 30A one I showed) and some extra power wires, you shouldn't have an issue with power.
Data:
You won't be able to to write to 900 LED's with a single Arduino Nano.
I have seen Nanos with both an Atmel 168 and Atmel 328. Neither of those have enough RAM to write to 900 LEDs.
The 168 has 1KB RAM and 328 has 2KB RAM if I recall.
Assuming it's running RGB with 8 bits per channel, thats 1 byte per channel, or 3 bytes per LED.
(maybe 4? I don't fully remember which addressing scheme the WS2812B used)
There's also the overhead of everything else happening on the Arduino.
Given that, with 2 KB of RAM with a Nano based on the 328P, you'll probably be able to run 500 - 600 LEDs,
simply because the data for the LED needs to be kept in RAM, which is limited.
If you use an Arduino Mega, that quadruples the RAM to 8 KB, which gets you 2000-2400 LEDs.
So you will have enough RAM to run 900 LEDs if you use a Mega.
Another suggesion: if you want to stick to small boards like the Nano, try one of the STM32 boards.
I have not tried the WS2812B LEDs work on it, but given how popular the board and LEDs are, it should be supported.
The cheap boards based on the STM32F103C8 have 20KB of RAM, which is more then the Mega, and it's also the size of the Nano.
Just note that you need a special programmer for those boards.
There is also sometimes a refresh rate limit that goes down with more LEDs, due to daisy chaining, but as long as you're not trying to go above ~100Hz, I doubt that would be a limitation
Hope this helps!
@@TonyTascioglu thanks for all your time and this mean a lot... And I'm planning to use it with esp32 soo it's more powerful and hope it can push data to more leds
Hello tony...can i contact you through email? I would like to ask you something regarding my project...from the 🇵🇭🇵🇭🇵🇭here...