I’m new at coding LED’s and I need some help to get started.
Do you have a great tutorial to get started with FastLED?
I do know how to change each individually LED’s color and so on, but I get totaly lost when I see a code like this:
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB( 255, 255, 255);
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Black;
delay(80);
}
or just something like this:
for (int i=0; i<LED_COUNT*10; i++)
{
rainbow(i);
delay(100); // Delay between rainbow slides
}
Hello @Mathias_Haugaard_Mic
the second example you have there, is not FastLed code. It uses a different library.
The code you show in the first example is a for loop.
if you don’t understand what a for loop does, you need to start with some C++ programming basic tutorials to teach you loops, counters, arrays and conditional statements.
If you do understand the for loop, then all you are doing is assigning a colour using RGB to the ‘dot’ in the array ‘leds[]’
If you’re new to Arduino, C, and/or C++, I would recommend starting simple with the Arduino tutorials: https://www.arduino.cc/en/Tutorial/BuiltInExamples
Specifically, the “Control Structures” section seems like it would help you get started.
In your first example the for loop increments a counter ‘dot’ from 0 to the number of LEDs in the strip.
Then using that counter as an index into the array that represents the strip of leds, it sets each led to white, shows it, then sets it to black (off), then loops rounds again, working its way through each led on the strip.
This would produce a white dot, that appears to move or travel along the strip.