Hi,
Can anyone explain how I can access individual leds on a WS2812b matrix on a node mcu esp8266?
I am able to apply built in effects but I’d like to set colour and brightness settings for each individual led.
I built a night light for my kids that slowly fades from blue to (almost) red and back using the code below on an arduino nano. How do I accomplish the same thing on an esp8266 device?
More generally, how can I access a specific led in a matrix and change its values based on a function?
#include <FastLED.h>
#define DATA_PIN 6
#define NUM_LEDS 16
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define MaxBrightness 200
#define MinBrightness 5
#define FADEDELAY 500
void setup(){
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// FastLED.setBrightness(BRIGHTNESS);
}
void loop(){
// fading color from blue to pink:
for( int colorStep=0; colorStep<195; colorStep++ ) {
// Set brightness via variable resistor (knob)
int val = analogRead(2);
int NumtToBrightness = map(val, 0, 1023, MinBrightness, MaxBrightness);
FastLED.setBrightness(NumtToBrightness);
int r = colorStep; // Redness starts at zero and goes up to full
int b = 255-colorStep; // Blue starts at full and goes down to zero
int g = 0; // No green needed to go from blue to red
fill_solid(leds,NUM_LEDS,CRGB(r,g,b));
FastLED.show();
delay(FADEDELAY);
}
// fading color from pink to blue:
for (int colorStep=194; colorStep>=0; colorStep-- ){
// Set brightness via variable resistor (knob)
int val = analogRead(2);
int NumtToBrightness = map(val, 0, 1023, MinBrightness, MaxBrightness);
FastLED.setBrightness(NumtToBrightness);
int r=colorStep;
int g=0;
int b=255-colorStep;
fill_solid(leds,NUM_LEDS,CRGB(r,g,b));
FastLED.show();
delay(FADEDELAY);
}
}