I'm fairly new at writing Arduino code and am confused by a block of code.
When executed, a blue dot travels down the LED strip and eventually loops back to the start.
#include <FastLED.h>
#define NUM_LEDS 150
#define DATA_PIN 4
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB::Blue;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Black;
delay(30);
}
}
Following the void loop logic...
Points of confusion
leds[dot] = CRGB::Black;
line.The first loop will have leds[0] turn blue, then it will display it on the light strip with FastLED.show(). Next it will make the same leds[0] turn black, however it will only display that in the second iteration of the loop.
The second loop will do the same to leds[1], and so on.