Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define USE_OCTOWS2811
- #include <OctoWS2811.h>
- #include <FastLED.h>
- #include <LEDMatrix.h>
- #define MATRIX_WIDTH 48 // Set this negative if physical led 0 is opposite to where you want logical 0
- #define MATRIX_HEIGHT 24 // Set this negative if physical led 0 is opposite to where you want logical 0
- #define MATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX // See top of LEDMatrix.h for matrix wiring types
- cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;
- void setup()
- {
- FastLED.addLeds<OCTOWS2811>(leds[0], (MATRIX_HEIGHT / 8) * MATRIX_WIDTH);
- FastLED.setBrightness(255);
- FastLED.clear(true);
- delay(500);
- FastLED.showColor(CRGB::Red);
- delay(500);
- FastLED.showColor(CRGB::Lime);
- delay(500);
- FastLED.showColor(CRGB::Blue);
- delay(500);
- FastLED.showColor(CRGB::White);
- delay(500);
- FastLED.clear(true);
- }
- void loop()
- {
- HuePlasma();
- FastLED.show();
- delay(20);
- }
- void HuePlasma()
- {
- static uint16_t PlasmaTime = 0, PlasmaShift = 0;
- #define PLASMA_X_FACTOR 24
- #define PLASMA_Y_FACTOR 24
- int16_t r, h;
- int x, y;
- if (PlasmaShift == 0)
- PlasmaShift = (random8(0, 5) * 32) + 64;
- for (x = 0; x < MATRIX_WIDTH; x++)
- {
- for (y = 0; y < MATRIX_HEIGHT; y++)
- {
- r = sin16(PlasmaTime) / 256;
- h = sin16(x * r * PLASMA_X_FACTOR + PlasmaTime) + cos16(y * (-r) * PLASMA_Y_FACTOR + PlasmaTime) + sin16(y * x * (cos16(-PlasmaTime) / 256) / 2);
- leds(x, y) = CHSV((h / 256) + 128, 255, 255);
- }
- }
- if ( (PlasmaTime + PlasmaShift) < PlasmaTime )
- {
- PlasmaTime += PlasmaShift;
- PlasmaShift = (random8(0, 5) * 32) + 64;
- }
- else
- PlasmaTime += PlasmaShift;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement