Advertisement
Av8tor

NeoPixel Test Sketch 2

Sep 4th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.50 KB | None | 0 0
  1. /*
  2.  *                       NeoPixel Test Sketch 2
  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 leds3[NUM_LEDS];
  12. CRGB leds4[NUM_LEDS];
  13. uint8_t gBrightness = 128;
  14.  
  15. void setup() {
  16.   Serial.begin(9600);      // open the serial port at 9600 bps:
  17.  
  18.   FastLED.addLeds<WS2812, 3>(leds2, NUM_LEDS); // Binary 2 position
  19.   FastLED.addLeds<WS2812, 4>(leds1, NUM_LEDS); // Binary 1 position
  20.   FastLED.addLeds<WS2812, 5>(leds3, NUM_LEDS); // Binary 4 position
  21.   FastLED.addLeds<WS2812, 6>(leds4, NUM_LEDS); // Binary 8 position
  22. }
  23.  
  24. void loop()
  25. {
  26.   FastLED.clear();
  27.   void redLeds();
  28.   Serial.println("beginning of void loop");
  29.   void greenLeds();
  30.   void blueLeds();
  31.   void whiteLeds();
  32.   void magentaLeds();
  33.   void cyanLeds();
  34.   void yellowLeds();
  35.   void purpleLeds();
  36.   Serial.println("end of void loop");
  37. }
  38.  
  39. void redLeds()
  40. {
  41.   Serial.println("redLeds function");
  42.  
  43.   for (int i = 0; i < NUM_LEDS; i++)
  44.  {
  45.     // set our current dot to red
  46.     leds1[i] = CRGB::Red;
  47.     FastLED.show(gBrightness);
  48.     // clear our current dot before we move on
  49.     leds1[i] = CRGB::Black;
  50.     delay(100);
  51.   }
  52.   // draw led data for the first strand into leds
  53.   fill_solid(leds1, NUM_LEDS, CRGB::Red);
  54.   FastLED[1].showLeds(gBrightness);
  55.   delay(500);
  56. }
  57.  
  58. void greenLeds()
  59. {
  60.   Serial.println("greenLeds function");
  61.  
  62.   for (int i = 0; i < NUM_LEDS; i++)
  63. {
  64.     // set our current dot to Green
  65.     leds2[i] = CRGB::Green;
  66.     FastLED.show(gBrightness);
  67.     // clear our current dot before we move on
  68.     leds2[i] = CRGB::Black;
  69.     delay(100);
  70. }
  71.   // draw led data for the second strand into leds
  72.   fill_solid(leds2, NUM_LEDS, CRGB::Green);
  73.   FastLED[0].showLeds(gBrightness);
  74.   delay(500);
  75. }
  76.  
  77.  
  78. void blueLeds()
  79. {
  80.   Serial.println("blueLeds function");
  81.  
  82.   for (int i = 0; i < NUM_LEDS; i++)
  83. {
  84.     // set our current dot to Blue
  85.     leds3[i] = CRGB::Blue;
  86.     FastLED.show(gBrightness);
  87.     // clear our current dot before we move on
  88.     leds3[i] = CRGB::Black;
  89.     delay(100);
  90. }
  91.   // draw led data for the third strand into leds
  92.   fill_solid(leds3, NUM_LEDS, CRGB::Blue);
  93.   FastLED[2].showLeds(gBrightness);
  94.   delay(500);
  95. }
  96.  
  97. void whiteLeds()
  98. {
  99.   Serial.println("whiteLeds function");
  100.  
  101.   for (int i = 0; i < NUM_LEDS; i++)
  102. {
  103.     // set our current dot to White
  104.     leds4[i] = CRGB::White;
  105.     FastLED.show(gBrightness);
  106.     // clear our current dot before we move on
  107.     leds4[i] = CRGB::Black;
  108.     delay(100);
  109. }
  110.   // draw led data for the fourth strand into leds
  111.   fill_solid(leds4, NUM_LEDS, CRGB::White);
  112.   FastLED[3].showLeds(gBrightness);
  113.   delay(500);
  114. }
  115.  
  116. void magentaLeds()
  117. {
  118.   Serial.println("MagentaLeds function");
  119.  
  120.   for (int i = 0; i < NUM_LEDS; i++)
  121.  {
  122.     // set our current dot to Magenta
  123.     leds1[i] = CRGB::Magenta;
  124.     FastLED.show(gBrightness);
  125.     // clear our current dot before we move on
  126.     leds1[i] = CRGB::Black;
  127.     delay(100);
  128.   }
  129.   // draw led data for the first strand into leds
  130.   fill_solid(leds1, NUM_LEDS, CRGB::Magenta);
  131.   FastLED[1].showLeds(gBrightness);
  132.   delay(500);
  133. }
  134.  
  135. void cyanLeds()
  136. {
  137.   Serial.println("CyanLeds function");
  138.  
  139.   for (int i = 0; i < NUM_LEDS; i++)
  140. {
  141.     // set our current dot to Cyan
  142.     leds2[i] = CRGB::Cyan;
  143.     FastLED.show(gBrightness);
  144.     // clear our current dot before we move on
  145.     leds2[i] = CRGB::Black;
  146.     delay(100);
  147. }
  148.   // draw led data for the second strand into leds
  149.   fill_solid(leds2, NUM_LEDS, CRGB::Cyan);
  150.   FastLED[0].showLeds(gBrightness);
  151.   delay(500);
  152. }
  153.  
  154.  
  155. void yellowLeds()
  156. {
  157.   Serial.println("YellowLeds function");
  158.  
  159.   for (int i = 0; i < NUM_LEDS; i++)
  160. {
  161.     // set our current dot to Yellow
  162.     leds3[i] = CRGB::Yellow;
  163.     FastLED.show(gBrightness);
  164.     // clear our current dot before we move on
  165.     leds3[i] = CRGB::Black;
  166.     delay(100);
  167. }
  168.   // draw led data for the third strand into leds
  169.   fill_solid(leds3, NUM_LEDS, CRGB::Yellow);
  170.   FastLED[2].showLeds(gBrightness);
  171.   delay(500);
  172. }
  173.  
  174. void purpleLeds()
  175. {
  176.   Serial.println("PurpleLeds function");
  177.  
  178.   for (int i = 0; i < NUM_LEDS; i++)
  179. {
  180.     // set our current dot to Purple
  181.     leds4[i] = CRGB::Purple;
  182.     FastLED.show(gBrightness);
  183.     // clear our current dot before we move on
  184.     leds4[i] = CRGB::Black;
  185.     delay(100);
  186. }
  187.   // draw led data for the fourth strand into leds
  188.   fill_solid(leds4, NUM_LEDS, CRGB::Purple);
  189.   FastLED[3].showLeds(gBrightness);
  190.   delay(500);
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement