Advertisement
Av8tor

NeoPixel Test Sketch 1

Sep 4th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.76 KB | None | 0 0
  1. /*
  2.                                     NeoPixel Test Sketch 1
  3.    Testing NeoPixel sketches
  4.    To be used in a small kaleidoscope binary clock
  5. */
  6. #include "FastLED.h"
  7. #define NUM_LEDS 4
  8.  
  9. CRGB leds1[NUM_LEDS];
  10. CRGB leds2[NUM_LEDS];
  11. CRGB leds4[NUM_LEDS];
  12. CRGB leds8[NUM_LEDS];
  13. uint8_t gBrightness = 128;
  14.  
  15. void setup()
  16. {
  17.   FastLED.addLeds<WS2812, 3>(leds1, NUM_LEDS); // Binary 2 position
  18.   FastLED.addLeds<WS2812, 4>(leds2, NUM_LEDS); // Binary 1 position
  19.   FastLED.addLeds<WS2812, 5>(leds4, NUM_LEDS); // Binary 4 position
  20.   FastLED.addLeds<WS2812, 6>(leds8, NUM_LEDS); // Binary 8 position
  21. }
  22.  
  23. void loop()
  24. {
  25.  
  26.   for (int i = 0; i < NUM_LEDS; i++)
  27.   {
  28.     FastLED.clear();
  29.     // set our current dot to red
  30.     leds1[i] = CRGB::Red;
  31.     FastLED.show(gBrightness);
  32.     // clear our current dot before we move on
  33.     leds1[i] = CRGB::Black;
  34.     delay(100);
  35.   }
  36.   // draw led data for the first strand into leds
  37.   fill_solid(leds1, NUM_LEDS, CRGB::Red);
  38.   FastLED[1].showLeds(gBrightness);
  39.   delay(500);
  40.  
  41.   for (int i = 0; i < NUM_LEDS; i++)
  42.   {
  43.     // set our current dot to Green
  44.     leds2[i] = CRGB::Green;
  45.     FastLED.show(gBrightness);
  46.     // clear our current dot before we move on
  47.     leds2[i] = CRGB::Black;
  48.     delay(100);
  49.   }
  50.   // draw led data for the second strand into leds
  51.   fill_solid(leds2, NUM_LEDS, CRGB::Green);
  52.   FastLED[0].showLeds(gBrightness);
  53.   delay(500);
  54.  
  55.   for (int i = 0; i < NUM_LEDS; i++)
  56.   {
  57.     // set our current dot to Blue
  58.     leds4[i] = CRGB::Blue;
  59.     FastLED.show(gBrightness);
  60.     // clear our current dot before we move on
  61.     leds4[i] = CRGB::Black;
  62.     delay(100);
  63.   }
  64.   // draw led data for the third strand into leds
  65.   fill_solid(leds4, NUM_LEDS, CRGB::Blue);
  66.   FastLED[2].showLeds(gBrightness);
  67.   delay(500);
  68.  
  69.   for (int i = 0; i < NUM_LEDS; i++)
  70.   {
  71.     // set our current dot to White
  72.     leds8[i] = CRGB::White;
  73.     FastLED.show(gBrightness);
  74.     // clear our current dot before we move on
  75.     leds8[i] = CRGB::Black;
  76.     delay(100);
  77.   }
  78.   // draw led data for the fourth strand into leds
  79.   fill_solid(leds8, NUM_LEDS, CRGB::White);
  80.   FastLED[3].showLeds(gBrightness);
  81.   delay(500);
  82.   FastLED.clear();
  83.  
  84.   for (int i = 0; i < NUM_LEDS; i++)
  85.   {
  86.     FastLED.clear();
  87.     // set our current dot to Magenta
  88.     leds1[i] = CRGB::Magenta;
  89.     FastLED.show(gBrightness);
  90.     // clear our current dot before we move on
  91.     leds1[i] = CRGB::Black;
  92.     delay(100);
  93.   }
  94.   // draw led data for the first strand into leds
  95.   fill_solid(leds1, NUM_LEDS, CRGB::Magenta);
  96.   FastLED[1].showLeds(gBrightness);
  97.   delay(500);
  98.  
  99.   for (int i = 0; i < NUM_LEDS; i++)
  100.   {
  101.     // set our current dot to Cyan
  102.     leds2[i] = CRGB::Cyan;
  103.     FastLED.show(gBrightness);
  104.     // clear our current dot before we move on
  105.     leds2[i] = CRGB::Black;
  106.     delay(100);
  107.   }
  108.   // draw led data for the second strand into leds
  109.   fill_solid(leds2, NUM_LEDS, CRGB::Cyan);
  110.   FastLED[0].showLeds(gBrightness);
  111.   delay(500);
  112.  
  113.   for (int i = 0; i < NUM_LEDS; i++)
  114.   {
  115.     // set our current dot to Yellow
  116.     leds4[i] = CRGB::Yellow;
  117.     FastLED.show(gBrightness);
  118.     // clear our current dot before we move on
  119.     leds4[i] = CRGB::Black;
  120.     delay(100);
  121.   }
  122.   // draw led data for the third strand into leds
  123.   fill_solid(leds4, NUM_LEDS, CRGB::Yellow);
  124.   FastLED[2].showLeds(gBrightness);
  125.   delay(500);
  126.  
  127.   for (int i = 0; i < NUM_LEDS; i++)
  128.   {
  129.     // set our current dot to Purple
  130.     leds8[i] = CRGB::Purple;
  131.     FastLED.show(gBrightness);
  132.     // clear our current dot before we move on
  133.     leds8[i] = CRGB::Black;
  134.     delay(100);
  135.   }
  136.   // draw led data for the fourth strand into leds
  137.   fill_solid(leds8, NUM_LEDS, CRGB::Purple);
  138.   FastLED[3].showLeds(gBrightness);
  139.   delay(1000);
  140.   FastLED.clear();
  141.  
  142.  
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement