#include #define PIN1 2 //connect 12 Neopixel strip to Digital PIN6 #define PIN2 10 //connect 6 Neopixel strip to Digital PIN7 #define PIN3 6 // connect 24 Neopixel ring to Digital PIN8 #define PIN4 13 // connect 16 Neopixel ring to Digital PIN9 #define PIN5 10 // #define NUMPIXELS1 12 #define NUMPIXELS2 6 #define NUMPIXELS3 24 #define NUMPIXELS4 16 #define NUMPIXELS5 8 Adafruit_NeoPixel pixels1 = Adafruit_NeoPixel(NUMPIXELS1, PIN1, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS2, PIN2, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels3 = Adafruit_NeoPixel(NUMPIXELS3, PIN3, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels4 = Adafruit_NeoPixel(NUMPIXELS4, PIN4, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels5 = Adafruit_NeoPixel(NUMPIXELS5, PIN5, NEO_GRB + NEO_KHZ800); const int spPot = 0; // wire speed pot to Analog0 (Rings) const int spPot1 = 1; // wire speed pot to Analog1 (Strips) const int colorPot1 = 2; // wire color wheel pot to Analog2 (First Strip) const int colorPot2 = 3; // wire color wheel pot to Analog3 (Second Strip) const int colorPot3 = 4; // wire color wheel pot to Analog4 (Rings) const int colorPot4 = 5; // wire color wheel pot to Analog5 (Mini-Strip) //Neopixel loop variables unsigned int counter1 = 0; unsigned int counter2 = 0; unsigned int counter3 = 0; unsigned int counter4 = 0; unsigned int counter5 = 0; int brightness = 100; // 0 to 255 valid (1 to 100 work best) int colorW = 85; // 0 to 255 valid green is 85 int sp = 100; // 1000 to 10 work good (slow to fast) int spOther = 100; int ct = 3; // number of pixels on in a group int nGroups = 6; // number of groups (even divisible of pixels 1,2,3,4,5,6,10,12) //millis count variables unsigned long previousMillis1 = 0; // will store last time you ran your code unsigned long previousMillis2 = 0; unsigned long previousMillis3 = 0; unsigned long previousMillis4 = 0; unsigned long previousMillis5 = 0; void setup() { pixels1.begin(); pixels2.begin(); pixels3.begin(); pixels4.begin(); pixels5.begin(); pixels1.show(); pixels2.show(); pixels3.show(); pixels4.show(); pixels5.show(); pixels1.setBrightness(brightness); pixels2.setBrightness(brightness); pixels3.setBrightness(brightness); pixels4.setBrightness(brightness); pixels5.setBrightness(brightness); } void loop() { ring1(); ring2(); ring3(); ring4(); ring5(); } void ring1() { int spRead = analogRead(spPot1); // read speed pot sp = map(spRead, 0, 1023, 1000, 10); //sets sp to a value between 1000 and 10 (one second and 1/100 second unsigned long currentMillis = millis(); //get current millis value if (currentMillis - previousMillis1 >= sp) { //check if it is time to run code previousMillis1 = currentMillis; // save the last time you ran your code //your code int colorRead = analogRead(colorPot1); // read color pot int colorRead_1 = (2.5 ) * colorRead; colorRead_1 = map(colorRead_1, 0, 1023, 1, 4); // sets color read to 1 to 4 switch (colorRead_1) { case 1: colorW = 170; //blue break; case 2: colorW = 84; //green break; case 3: colorW = 42 ; //yellow break; case 4: colorW = 0; //red break; { } } for (int y = 0; y < NUMPIXELS1; y = y + NUMPIXELS1 / nGroups) { //number of groups loop for (int z = 0; z < ct; z++) { //pixels per group loop pixels1.setPixelColor(((counter1 + y + z) % NUMPIXELS1), Wheel1(colorW)); //set color pixels1.setPixelColor(((counter1 + y + z - ct) % NUMPIXELS1), pixels1.Color(0, 0, 0)); //set previous off } } pixels1.show(); counter1++; } } void ring2() { int spRead = analogRead(spPot1); // read speed pot sp = map(spRead, 0, 1023, 1000, 10); //sets sp to a value between 1000 and 10 (one second and 1/100 second unsigned long currentMillis = millis(); //get current millis value if (currentMillis - previousMillis2 >= spOther) { //check if it is time to run code previousMillis2 = currentMillis; // save the last time you ran your code //your code int colorRead = analogRead(colorPot2); // read color pot int colorRead_1 = (1.8 ) * colorRead; colorRead_1 = map(colorRead_1, 0, 1023, 1, 4); // sets color read to 1 to 4 switch (colorRead_1) { case 1: colorW = 170; //blue break; case 2: colorW = 84; //green break; case 3: colorW = 42 ; //yellow break; case 4: colorW = 0; //red break; } for (int y = 0; y < NUMPIXELS2; y = y + NUMPIXELS2 / nGroups) { //number of groups loop for (int z = 0; z < ct; z++) { //pixels per group loop pixels2.setPixelColor(((counter2 + y + z) % NUMPIXELS2), Wheel2(colorW)); //set color pixels2.setPixelColor(((counter2 + y + z - ct) % NUMPIXELS2), pixels2.Color(0, 0, 0)); //set previous off } } pixels2.show(); counter2++; } } void ring3() { int spRead = analogRead(spPot); // read speed pot sp = map(spRead, 0, 1023, 1000, 10); //sets sp to a value between 1000 and 10 (one second and 1/100 second unsigned long currentMillis = millis(); //get current millis value if (currentMillis - previousMillis3 >= spOther) { //check if it is time to run code previousMillis3 = currentMillis; // save the last time you ran your code //your code int colorRead = analogRead(colorPot3); // read color pot int colorRead_1 = (2.5 ) * colorRead; colorRead_1 = map(colorRead_1, 0, 1023, 1, 4); // sets color read to 1 to 4 switch (colorRead_1) { case 1: colorW = 170; //blue break; case 2: colorW = 84; //green break; case 3: colorW = 42 ; //yellow break; case 4: colorW = 0; //red break; } for (int y = 0; y < NUMPIXELS3; y = y + NUMPIXELS3 / nGroups) { //number of groups loop for (int z = 0; z < ct; z++) { //pixels per group loop pixels3.setPixelColor(((counter3 + y + z) % NUMPIXELS3), Wheel3(colorW)); //set color pixels3.setPixelColor(((counter3 + y + z - ct) % NUMPIXELS3), pixels3.Color(0, 0, 0)); //set previous off } } pixels3.show(); counter3++; } } void ring4() { int spRead = analogRead(spPot); // read speed pot sp = map(spRead, 0, 1023, 1000, 10); //sets sp to a value between 1000 and 10 (one second and 1/100 second unsigned long currentMillis = millis(); //get current millis value if (currentMillis - previousMillis3 >= spOther) { //check if it is time to run code previousMillis3 = currentMillis; // save the last time you ran your code //your code int colorRead = analogRead(colorPot3); // read color pot int colorRead_1 = (2.5 ) * colorRead; colorRead_1 = map(colorRead_1, 0, 1023, 1, 4); // sets color read to 1 to 4 switch (colorRead_1) { case 1: colorW = 170; //blue break; case 2: colorW = 84; //green break; case 3: colorW = 42 ; //yellow break; case 4: colorW = 0; //red break; } for (int y = 0; y < NUMPIXELS3; y = y + NUMPIXELS3 / nGroups) { //number of groups loop for (int z = 0; z < ct; z++) { //pixels per group loop pixels3.setPixelColor(((counter3 + y + z) % NUMPIXELS3), Wheel3(colorW)); //set color pixels3.setPixelColor(((counter3 + y + z - ct) % NUMPIXELS3), pixels3.Color(0, 0, 0)); //set previous off } } pixels3.show(); counter3++; } } void ring5() { /* int spRead = analogRead(spPot); // read speed pot sp = map(spRead, 0, 1023, 1000, 10); //sets sp to a value between 1000 and 10 (one second and 1/100 second */ unsigned long currentMillis = millis(); //get current millis value if (currentMillis - previousMillis4 >= spOther) { //check if it is time to run code previousMillis4 = currentMillis; // save the last time you ran your code //your code int colorRead = analogRead(colorPot4); // read color pot int colorRead_1 = (1.8 ) * colorRead; colorRead_1 = map(colorRead_1, 0, 1023, 1, 4); // sets color read to 1 to 4 switch (colorRead_1) { case 1: colorW = 170; //blue break; case 2: colorW = 84; //green break; case 3: colorW = 42 ; //yellow break; case 4: colorW = 0; //red break; } for (int y = 0; y < NUMPIXELS4; y = y + NUMPIXELS4 / nGroups) { //number of groups loop for (int z = 0; z < ct; z++) { //pixels per group loop pixels4.setPixelColor(((counter4 + y + z) % NUMPIXELS4), Wheel4(colorW)); //set color pixels4.setPixelColor(((counter4 + y + z - ct) % NUMPIXELS4), pixels4.Color(0, 0, 0)); //set previous off } } pixels4.show(); counter4++; } } uint32_t Wheel1(byte WheelPos) { WheelPos = 255 - WheelPos; if (WheelPos < 85) { return pixels1.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if (WheelPos < 170) { WheelPos -= 85; return pixels1.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return pixels1.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } uint32_t Wheel2(byte WheelPos) { WheelPos = 255 - WheelPos; if (WheelPos < 85) { return pixels2.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if (WheelPos < 170) { WheelPos -= 85; return pixels2.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return pixels2.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } uint32_t Wheel3(byte WheelPos) { WheelPos = 255 - WheelPos; if (WheelPos < 85) { return pixels3.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if (WheelPos < 170) { WheelPos -= 85; return pixels3.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return pixels3.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } uint32_t Wheel4(byte WheelPos) { WheelPos = 255 - WheelPos; if (WheelPos < 85) { return pixels4.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if (WheelPos < 170) { WheelPos -= 85; return pixels4.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return pixels4.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } uint32_t Wheel5(byte WheelPos) { WheelPos = 255 - WheelPos; if (WheelPos < 85) { return pixels5.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if (WheelPos < 170) { WheelPos -= 85; return pixels5.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return pixels5.Color(WheelPos * 3, 255 - WheelPos * 3, 0); }