ldirko

241 LED ring Perlin Fire

Jan 22nd, 2021
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //241 LED ring Perlin Fire
  2. //Fastled rgb led demo
  3. //Yaroslaw Turbin, 22.01.2021
  4. //https://vk.com/ldirko
  5. //https://www.reddit.com/user/ldirko/
  6.  
  7. //how it look in emulator https://wokwi.com/arduino/projects/288428295376077325
  8. // thx thx sutaburosu for leds circuit anв wokwi for awesome emulator
  9.  
  10. #include <FastLED.h>
  11.  
  12. #define LED_PIN     3
  13. #define NUM_COLS    17
  14. #define NUM_ROWS    17
  15. #define NUM_LEDS    NUM_COLS*NUM_ROWS
  16. #define LED_TYPE    WS2812
  17. #define COLOR_ORDER GRB
  18. CRGB leds[NUM_LEDS+1];
  19.  
  20. void setup() {FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);}
  21.  
  22. void loop() {
  23. int  a = millis();
  24. for (int j = 0; j < NUM_ROWS; j++) {
  25. for (int i = 0; i < NUM_COLS; i++) {
  26. leds[XY1(i,j)] = HeatColor(qsub8 (inoise8 (i * 80 , j * 80+ a , a /3),
  27. abs8(j - (NUM_ROWS-1)) * 255 / (NUM_ROWS+2)));
  28. // leds[XY1(i,j)] = CHSV (sin8(i*8+sin8(i*2+a/9))/2+sin8(j*8+sin8(j*8+a/8)/2),255,255);
  29. }}
  30. FastLED.show();
  31. }
  32.  
  33. byte XY1 (byte x, byte y) {
  34. static byte PlanarLookTable [] = {             //i made this lookup table in Excel ))))
  35. 241, 53, 54, 55, 56, 57, 58, 59, 0, 1, 2, 3, 4, 5, 6, 7, 241,
  36. 52, 241, 241, 103, 104, 105, 106, 107, 60, 61, 62, 63, 64, 65, 241, 241, 8,
  37. 51, 241, 102, 241, 144, 145, 146, 147, 108, 109, 110, 111, 112, 241, 66, 241, 9,
  38. 50, 101, 241, 143, 241, 177, 178, 179, 148, 149, 150, 151, 241, 113, 241, 67, 10,
  39. 49, 100, 142, 241, 176, 241, 202, 203, 180, 181, 182, 241, 152, 241, 114, 68, 11,
  40. 48, 99, 141, 175, 241, 201, 241, 219, 204, 205, 241, 183, 241, 153, 115, 69, 12,
  41. 47, 98, 140, 174, 200, 241, 218, 231, 220, 221, 206, 241, 184, 154, 116, 70, 13,
  42. 46, 97, 139, 173, 199, 217, 230, 239, 232, 233, 222, 207, 185, 155, 117, 71, 14,
  43. 45, 96, 138, 172, 198, 216, 229, 238, 241, 234, 223, 208, 186, 156, 118, 72, 15,
  44. 44, 95, 137, 171, 197, 215, 228, 237, 236, 235, 224, 209, 187, 157, 119, 73, 16,
  45. 43, 94, 136, 170, 196, 241, 214, 227, 226, 225, 210, 241, 188, 158, 120, 74, 17,
  46. 42, 93, 135, 169, 241, 195, 241, 213, 212, 211, 241, 189, 241, 159, 121, 75, 18,
  47. 41, 92, 134, 241, 168, 241, 194, 193, 192, 191, 190, 241, 160, 241, 122, 76, 19,
  48. 40, 91, 241, 133, 241, 167, 166, 165, 164, 163, 162, 161, 241, 123, 241, 77, 20,
  49. 39, 241, 90, 241, 132, 131, 130, 129, 128, 127, 126, 125, 124, 241, 78, 241, 21,
  50. 38, 241, 241, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 241, 241, 22,
  51. 241, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 241};
  52. return (PlanarLookTable[y*NUM_COLS+x]);
  53. }
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment