Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This #include statement was automatically added by the Particle IDE.
- #include "FastLED/FastLED.h"
- FASTLED_USING_NAMESPACE;
- const uint8_t kMatrixWidth = 12;
- const uint8_t kMatrixHeight = 23;
- #define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)
- #define NUM_LEDS (kMatrixWidth * kMatrixHeight)
- const bool kMatrixSerpentineLayout = true;
- uint16_t XY( uint8_t x, uint8_t y)
- {
- uint16_t i;
- if( kMatrixSerpentineLayout == false) {
- i = (y * kMatrixWidth) + x;
- }
- if( kMatrixSerpentineLayout == true) {
- if( y & 0x01) {
- uint8_t reverseX = (kMatrixWidth - 1) - x;
- i = (y * kMatrixWidth) + reverseX;
- } else {
- i = (y * kMatrixWidth) + x;
- }
- }
- return i;
- }
- CRGB leds[kMatrixWidth * kMatrixHeight];
- static uint16_t x;
- static uint16_t y;
- static uint16_t z;
- uint16_t speed = 3;
- uint16_t scale = 311;
- uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];
- void setup() {
- FastLED.addLeds<WS2812B,23,RGB>(leds,NUM_LEDS,0);
- FastLED.setBrightness(20);
- x = random16();
- y = random16();
- z = random16();
- }
- void fillnoise8() {
- for(int i = 0; i < MAX_DIMENSION; i++) {
- int ioffset = scale * i;
- for(int j = 0; j < MAX_DIMENSION; j++) {
- int joffset = scale * j;
- noise[i][j] = inoise8(x + ioffset,y + joffset,z);
- }
- }
- z += speed;
- }
- void loop() {
- static uint8_t ihue=0;
- fillnoise8();
- for(int i = 0; i < kMatrixWidth; i++) {
- for(int j = 0; j < kMatrixHeight; j++) {
- leds[XY(i,j)] = CHSV(noise[j][i],255,noise[i][j]);
- }
- }
- ihue+=1;
- LEDS.show();
- delay(10);
- }
Advertisement
Add Comment
Please, Sign In to add comment