Advertisement
Guest User

Untitled

a guest
Jan 8th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  1. // Main File for design sketches for my DIY VW symbol
  2. // Bits of sketch taken from Chemdoc77 and others--
  3.  
  4. #include "FastLED.h" //Always start FastLED sketches with this
  5. #define NUM_LEDS 50 //How many LEDs are you controlling?
  6. #define DATA_PIN 3 //What data pin are you connecting to on your controller?
  7. #define CHIPSET WS2812B //What chipset are your LEDs?
  8. #define BRIGHTNESS 50 //Enter a value between 0-255
  9. #define COLOR_ORDER GRB //If your colors are wrong on your LEDs, change the order of GRB
  10. //#define UPDATES_PER_SECOND 1000
  11.  
  12. //================ Setup LED Arrays =====================
  13. CRGB rawleds[NUM_LEDS];
  14. CRGBSet leds(rawleds, NUM_LEDS);
  15. CRGBSet leds1(leds(0, 24));
  16. CRGBSet leds2(leds(25, 50));
  17.  
  18.  
  19. struct CRGB * ledarray[] = {leds1, leds2}; // Make sure to include all of the arrays you set up above between the {}
  20.  
  21. uint8_t sizearray[] = {25, 25}; // size of each above arrays
  22.  
  23. CRGBPalette16 currentPalette; // Do not change
  24. TBlendType currentBlending; //Do not change
  25.  
  26. extern CRGBPalette16 myRedWhiteBluePalette; //Input palette name you define later
  27. extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;//Input palette name you define later
  28. //================ Setup =====================
  29. void setup() {
  30. delay( 3000 ); // power-up safety delay
  31. FastLED.addLeds<WS2812B, DATA_PIN, GRB>(rawleds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  32. FastLED.setBrightness( BRIGHTNESS );
  33.  
  34. FastLED.setMaxPowerInVoltsAndMilliamps(5, 1500); // Set power limit to make lights, not smoke.
  35. set_max_power_indicator_LED(13);
  36.  
  37. currentPalette = myRedWhiteBluePalette_p; //enter the palette name youd like you run
  38. currentBlending = LINEARBLEND; //NOBLEND OR LINEARBLEND
  39. }
  40. //================ Loop =====================
  41. void loop() {
  42. static uint8_t startIndex = 0;
  43. startIndex = startIndex + 1; /* motion speed */
  44. //================ Sequence ===================== //edit out or add effects here
  45. arrayfill(CRGB::White, 700);// fills the whole array
  46. arrayfill(CRGB::Blue, 700); // fills the whole array
  47. heartbeat();//Circle around outside, heartbeat on inside
  48. colorwipe_dot(0, CRGB::White, 200);// Fills one dot at a time
  49. colorwipe_dot(1, CRGB::Blue, 200);// Fills one dot at a time
  50. fill_solid(leds, NUM_LEDS - 1, CRGB::White); //turn LEDs off
  51. FillLEDsFromPaletteColors( startIndex);//linear motion effect from palette defined below
  52. colorwipe_dot(0, CRGB::White, 200);// Fills one dot at a time
  53. colorwipe_dot(1, CRGB::Blue, 200);// Fills one dot at a time
  54. FastLED.delay(30);
  55. }
  56. //================ Functions =====================
  57.  
  58. //Define your functions here
  59.  
  60. //--------------------- Colorwipe ---------------------
  61.  
  62. void colorwipe_dot(uint8_t y, CRGB color, uint32_t wait) { //Note: y is ledarray number
  63. for (uint8_t dot = 0; dot < sizearray[y]; dot++) {
  64. ledarray[y][dot] = color;
  65. FastLED.delay(80);
  66. ledarray[y][dot] = CRGB::White;
  67. }
  68. }
  69. //--------------------- Arrayfill ---------------------
  70. void arrayfill(CRGB color, uint16_t wait) {
  71.  
  72. for (uint8_t x = 0; x < 2; x++) {
  73. fill_solid(ledarray[x], sizearray[x], color);
  74. FastLED.show();
  75. delay(wait);
  76. fill_solid( ledarray[x], sizearray[x], CRGB::Black);
  77. FastLED.show();
  78.  
  79. }
  80. }
  81. //--------------------- Heartbeat ---------------------
  82. void heartbeat() {
  83. for (byte i = 0; i < 5; i++) {
  84. static uint8_t hue;
  85. for (int i = 0; i < NUM_LEDS / 2; i++) {
  86. // fade everything out
  87. leds.fadeToBlackBy(40);
  88.  
  89. // let's set an led color
  90. leds[i] = CRGB::Blue;
  91.  
  92. // now, let's first half leds to the top half leds,
  93. leds(NUM_LEDS / 2, NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1 , NUM_LEDS - 1);
  94. FastLED.delay(33);
  95. }
  96. }
  97. }
  98. //--------------------- FillLEDsFromPaletteColors ---------------------
  99. void FillLEDsFromPaletteColors( uint8_t colorIndex)
  100. {
  101. uint8_t brightness = 255;
  102. for (byte i = 0; i < 3; i++) {
  103. for ( int i = 0; i < NUM_LEDS; i++) {
  104. leds[i] = ColorFromPalette( myRedWhiteBluePalette_p, colorIndex, BRIGHTNESS, currentBlending);
  105. colorIndex +=3;
  106. FastLED.delay(20);
  107. }
  108. }
  109. }
  110.  
  111. //--------------------- FillLEDsFromPaletteColors ---------------------
  112.  
  113. //This is where you program your palette. Make sure your _p name is the same here as it is above.Change * in every CRGB::***** to a CRGB color .
  114. const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
  115. {
  116. CRGB::Red,
  117. CRGB::Black,
  118. CRGB::Yellow,
  119. CRGB::Black,
  120.  
  121. CRGB::Red,
  122. CRGB::Black,
  123. CRGB::Yellow,
  124. CRGB::Black,
  125.  
  126. CRGB::Red,
  127. CRGB::Black,
  128. CRGB::Yellow,
  129. CRGB::Black,
  130. CRGB::Red,
  131. CRGB::Black,
  132. CRGB::Black,
  133. CRGB::Yellow
  134. };
  135.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement