Skip to content

Instantly share code, notes, and snippets.

@StefanPetrick
Created December 19, 2015 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save StefanPetrick/b7ae1e0fc7ca6eb4e698 to your computer and use it in GitHub Desktop.
Save StefanPetrick/b7ae1e0fc7ca6eb4e698 to your computer and use it in GitHub Desktop.
#include<FastLED.h>
#define LED_PIN 12
#define BRIGHTNESS 255
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS (240)
CRGB leds[NUM_LEDS];
static uint32_t x;
static uint32_t y;
static uint32_t z;
uint16_t speed = 1300;
uint16_t scale = 1000;
uint8_t noise[NUM_LEDS];
void setup() {
LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
LEDS.setBrightness(BRIGHTNESS);
x = random16();
y = random16();
z = random16();
}
void fillnoise16() {
for (int i = 0; i < NUM_LEDS; i++) {
uint8_t data = inoise16(x , y + (i * scale), z) >> 8;
noise[i] = data;
}
x += speed;
}
void mapNoiseToLEDs(){
for (int i = 0; i < NUM_LEDS; i++) {
uint8_t index = noise[i] >> 2;
uint8_t bri = noise[i];
CRGB color = CHSV( index, 255, bri);
leds[i] = color;
}
}
void loop() {
fillnoise16();
mapNoiseToLEDs();
LEDS.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment