#include <FastLED.h>
#define DATA_PIN 3 //set your datapin
#define LED_TYPE WS2812B //leds type
#define COLOR_ORDER GRB //color order of leds
#define MAX_POWER_MILLIAMPS 800 //write here your power in milliamps. default i set 800 mA for safety
#define NUM_COLS 16
#define NUM_ROWS 16
#define NUM_LEDS 256
CRGB leds[NUM_LEDS + 1];
byte potpin = 0; // analog pin used to connect the potentiometer1
byte potpin1 = 1; // analog pin used to connect the potentiometer2
byte BRIGHTNESS = 255;
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS)
// .setCorrection( TypicalLEDStrip )
;
// FastLED.setMaxPowerInVoltsAndMilliamps( 5, MAX_POWER_MILLIAMPS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
}
void loop() {
int a= millis()/4;
int a1 = a/2;
int a2= a/3;
fadeToBlackBy(leds, NUM_LEDS, 20);
// for (int i = 0; i < 16; i++) {
// byte y = sin8(i*slider1()+a)*16/255;
// nblend (leds [XY(i,y)], CHSV(i*255/15+a2,255,255),64);
// }
byte sl1= slider1()/4;
byte sl2= slider2()/4;
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
int index = XY(x, y);
// byte xoffs = (sin8(x*sl1)+cos8(y*sl2+a2))/2;
byte ind = sin8(x*sl1+sin8(x*2+a2))/2+sin8(y*sl2+sin8(y*2+a1)/2)/2;
byte yoffs = inoise8(x*(sin8(a2)/8+32)+a1, y*(cos8(a1)/8+32), a2);
leds[index] = CHSV ((ind+yoffs)/2, 255, 255);
// leds[index].setHue(yoffs);
}
}
LEDS.show();
}
uint16_t XY(byte x, byte y) { // calculate index in leds from XY coordinates for planar mapping
uint16_t ledsindex =y*NUM_COLS+x;
return (ledsindex);
}
byte slider1(){
int val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 255); // map value between 0 and 255
return (val);
}
byte slider2(){
int val = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 255); // map value between 0 and 255
return (val);
}FPS: 0
Power: 0.00W
Power: 0.00W