ldirko

DNA

Jul 31st, 2020 (edited)
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. //2 DNA spiral
  2. //16x16 rgb led matrix demo
  3. //Yaroslaw Turbin 31.07.2020
  4. //https://vk.com/ldirko
  5. //https://www.reddit.com/user/ldirko/
  6. //https://www.reddit.com/r/FastLED/comments/gogs4n/i_made_7x11_matrix_for_my_ntp_clock_project_then/
  7.  
  8.  
  9. #include "FastLED.h"
  10.  
  11. // Matrix size
  12. #define NUM_ROWS 16
  13. #define NUM_COLS 16
  14.  
  15. // LEDs pin
  16. #define DATA_PIN 3
  17.  
  18. // LED brightness
  19. #define BRIGHTNESS 255
  20.  
  21. #define NUM_LEDS NUM_ROWS * NUM_COLS
  22.  
  23. // Define the array of leds
  24. CRGB leds[NUM_LEDS];
  25.  
  26. #define mn 255/(NUM_COLS*2)
  27. #define speeds 30
  28. #define freq 10
  29.  
  30. void setup() {
  31. FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  32. FastLED.setBrightness(BRIGHTNESS);
  33. }
  34.  
  35. void loop() {
  36.  
  37. fadeToBlackBy(leds, NUM_LEDS, 100);
  38.  
  39. for (int i = 0; i < NUM_ROWS; i++)
  40. {
  41. uint16_t ms = millis();
  42. leds [i * NUM_COLS + beatsin8(speeds, 0, NUM_COLS-1, 0, i * freq)] += CHSV( ms / 29+i*255/(NUM_ROWS-1), 255, beatsin8(speeds, 30, BRIGHTNESS, 0, i * mn+64));
  43. leds [i * NUM_COLS + beatsin8(speeds, 0, NUM_COLS-1, 0, 128 + i * freq)] += CHSV( ms / 29+i*255/(NUM_ROWS-1)+128, 255, beatsin8(speeds, 30, BRIGHTNESS, 0, i * mn + 128+64));
  44. }
  45.  
  46. blur2d( leds, NUM_COLS, NUM_ROWS, 64);
  47.  
  48. FastLED.delay(1);
  49.  
  50. }
  51.  
  52.  
  53. uint16_t XY (uint8_t x, uint8_t y) { return (y * NUM_COLS + x);}
Add Comment
Please, Sign In to add comment