Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- By: ldirko (on Reddit)
- https://editor.soulmatelights.com/gallery/597-sin-dots
- Minimum width/height of 4.
- */
- #include <FastLED.h>
- #define LED_PIN 12
- const uint8_t matrixWidth = 16;
- const uint8_t matrixHeight = 16;
- #define NUM_LEDS (matrixWidth*matrixHeight)
- #define matrixSerpentineLayout true
- CRGB leds[NUM_LEDS];
- void setup() {
- delay(1000);
- Serial.begin(115200);
- FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
- FastLED.setBrightness(64);
- } // setup()
- void loop () {
- EVERY_N_MILLIS(23) {
- sindots();
- }
- FastLED.show();
- } // loop()
- void sindots() {
- fadeToBlackBy(leds, NUM_LEDS, 15);
- byte t1 = millis() / 20;
- byte t2 = sin8(t1) / 4 * 2;
- for (uint16_t i = 0; i < 13; i++) {
- byte x = sin8(t1 + i * 20) * matrixWidth / 256;
- byte y = sin8(t2 + i * 20) * matrixHeight / 256;
- static int maxVal = 0;
- if (XY(x, y) > maxVal) {maxVal = XY(x,y); Serial.println(maxVal); }
- leds[XY(x, y)] = CHSV(i * 255 / 13, 255, 255);
- }
- blur2d(leds, matrixWidth, matrixHeight, 16);
- }
- uint16_t XY( uint8_t x, uint8_t y) {
- uint16_t i;
- if ( matrixSerpentineLayout == false) {
- i = (y * matrixWidth) + x;
- }
- if ( matrixSerpentineLayout == true) {
- if ( y & 0x01) {
- uint8_t reverseX = (matrixWidth - 1) - x;
- i = (y * matrixWidth) + reverseX;
- } else {
- i = (y * matrixWidth) + x;
- }
- }
- return i;
- } // XY()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement