///////////////////////////////////////////////This is the Halloween Test Program for use with the AtmosFX animations for a whole house LED light show 2024///////////////////////////////////////////////////////////////////////// // This sketch is designed for the Animated LED Lighting, LLC Arduino Nano Shield A18804. It samples the frequency signal level measured by the Mixed Signal // Integration MSGEQ7 and converts these values into Pulse Width Modulated (PWM) signals. These PWM signals are fed into the four inputs of the Allegro MicroSystems A80804 LED driver. // The LED driver controls the current through four independent channels of standard RGBW LED light strips. // This progam supports generic RGBW LED lights strips and Individually addressable LED light strips //I added the code below from the Basic Neopixel strip test. This is needed for individually addressable LED strips// #include #ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket #endif // Which pin on the Arduino is connected to the NeoPixels? #define LED_PIN1 13 //// Signal pin for the first LED strip //#define LED_PIN2 4 //// Signal pin for the second LED strip //#define LED_PIN3 12 //// Signal pin for the third LED strip // #define LED_PIN4 10 //// Signal pin for the fourth LED strip // How many NeoPixels are attached to the Arduino? If you don't know, start with 300 and after every test run, change the number up or down until you find the end of your strip //#define LED_COUNT 123 #define LED_COUNT1 300 //#define LED_COUNT2 300 //#define LED_COUNT3 300 // #define LED_COUNT4 70 // NeoPixel brightness, 0 (min) to 255 (max) #define BRIGHTNESS 80 // Set BRIGHTNESS to about 1/5 (max = 255) // Declare our NeoPixel strip object: Adafruit_NeoPixel stripA(LED_COUNT1, LED_PIN1, NEO_GRB + NEO_KHZ800); //Adafruit_NeoPixel stripB(LED_COUNT2, LED_PIN2, NEO_GRB + NEO_KHZ800); //Adafruit_NeoPixel stripC(LED_COUNT3, LED_PIN3, NEO_GRB + NEO_KHZ800); // Adafruit_NeoPixel stripD(LED_COUNT4, LED_PIN4, NEO_GRB + NEO_KHZ800); // Argument 1 = Number of pixels in NeoPixel strip // Argument 2 = Arduino pin number (most are valid) // Argument 3 = Pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) //declarations and pin numbers int strobePin = 7; // Strobe Pin on the MSGEQ7 int resetPin = 8; // Reset Pin on the MSGEQ7 int outPin = A7; // Output Pin on the MSGEQ7 int tvalue = 255; // brightness Value of the test sequence int level[7]; // An array to hold the values from the 7 frequency bands int wvalue[7]; //An array to store the mapped value of the individual levels for the first strip int xvalue[7]; //An array to store the mapped value of the individual levels for the second strip int yvalue[7]; //An array to store the mapped value of the individual levels for the third strip int zvalue[7]; //An array to store the mapped value of the individual levels for the fourth strip int PWMvalue = 0; int LEDbin[7] = {0,1,2,3,4,5,6}; //This array just assigns a number to the bins int dLEDs1 = (10); // Delay for the LEDs on the first strip int dLEDs2 = (15); // Delay for the second strip int dLEDs3 = (12); // Delay for the third strip int test = (1000); //Delay for the test loop uint32_t Ab = stripA.Color(0, 0, 255);//Assign Blue color uint32_t Ar= stripA.Color(255, 0, 0); //Assign Red color uint32_t Ag = stripA.Color(0, 255, 0); //Assign Green Color uint32_t Arb = stripA.Color(127, 0, 127); //Assign Red and Blue together at half intensity uint32_t Arg= stripA.Color(127, 127, 0); //Assign Red and Green together at half intensity uint32_t Agb = stripA.Color(0, 127, 127); //Assign Green and Blue togehter at half intensity uint32_t Argb = stripA.Color(127,127,127); //Assing Red, Green and Blue together to make white uint32_t Bb = stripB.Color(0, 0, 255); uint32_t Br= stripB.Color(255, 0, 0); uint32_t Bg = stripB.Color(0, 255, 0); uint32_t Brb = stripB.Color(127, 0, 127); uint32_t Brg= stripB.Color(127, 127, 0); uint32_t Bgb = stripB.Color(0, 127, 127); uint32_t Brgb = stripB.Color(127,127,127); // uint32_t Cb = stripC.Color(0, 0, 255); // uint32_t Cr= stripC.Color(255, 0, 0); // uint32_t Cg = stripC.Color(0, 255, 0); // uint32_t Crb = stripC.Color(127, 0, 127); // uint32_t Crg= stripC.Color(127, 127, 0); // uint32_t Cgb = stripC.Color(0, 127, 127); // uint32_t Crgb = stripC.Color(127,127,127); int redPin=9; //pin enabled to supply RED LEDs int greenPin=6; //pin enabled to supply GREEN LEDs int bluePin=5; //pin enabled to supply BLUE LEDs int whitePin=3; //pin enable to supply WHITE LEDs int Rscale=5; //Use this to scale any particular color int Gscale=90; int Bscale=50; int Wscale=120; void setup() { // Startup Test Mode so you can check all your lights. This test only runs for generic RGBW LEDs for (int i=0; i<4; i++){ analogWrite(redPin, tvalue); //tvalue=test value delay(test); analogWrite(redPin, 0); analogWrite(greenPin, tvalue); delay(test); analogWrite(greenPin, 0); analogWrite(bluePin, tvalue); delay(test); analogWrite(bluePin, 0); analogWrite(whitePin, tvalue); delay(test); analogWrite(whitePin, 0); delay(test); } // Define our pin modes // for (int i=0; i<7; i++){ // pinMode(LEDpin[i], OUTPUT); // } pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); pinMode(whitePin, OUTPUT); //Serial.begin (9600); stripA.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) //stripB.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) //stripC.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) // stripD.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) stripA.show(); // Turn OFF all pixels ASAP //stripB.show(); // Turn OFF all pixels ASAP //stripC.show(); // Turn OFF all pixels ASAP // stripD.show(); // Turn OFF all pixels ASAP stripA.setBrightness(BRIGHTNESS); // Set BRIGHTNESS to about 1/5 (max = 255) //stripB.setBrightness(BRIGHTNESS); // Set BRIGHTNESS to about 1/5 (max = 255) //stripC.setBrightness(BRIGHTNESS); // Set BRIGHTNESS to about 1/5 (max = 255) // stripD.setBrightness(BRIGHTNESS); // Set BRIGHTNESS to about 1/5 (max = 255) ////////////////////Setting pin modes////////////////////////////////// pinMode (strobePin, OUTPUT); pinMode (resetPin, OUTPUT); pinMode (outPin, INPUT); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); pinMode(whitePin, OUTPUT); // Create an initial state for our pins on the MSGEQ7 chip digitalWrite (resetPin, LOW); digitalWrite (strobePin, LOW); delay (1); // Reset the MSGEQ7 as per the datasheet timing diagram digitalWrite (resetPin, HIGH); delay (1); digitalWrite (resetPin, LOW); digitalWrite (strobePin, HIGH); delay (1); } void loop() { // Cycle through each frequency band by pulsing the strobe pin. for (int i = 0; i < 7; i++) { digitalWrite (strobePin, LOW); delayMicroseconds (20); // Delay necessary due to timing diagram level[i] = analogRead (outPin); //this is the physical read pin and the value found xvalue[i] = map(level[i], 0, 1023, 0, 150); // x value is amplitude for the first individually addressable strip. if(xvalue[i] < 30){///scale factor to remove the noise floor xvalue[i]=1; } yvalue[i] = map(level[i], 0, 1023, 0, 150); // y value is the amplitude for the second indAddr strip if(yvalue[i] < 20){ //scale factor to remove the noise floor yvalue[i]=1; } // wvalue[i] = map(level[i], 0, 1023, 0, 172); // y value is the amplitude for the third indAddr strip // if(wvalue[i] < 25){ //scale factor to remove the noise floor // wvalue[i]=1; // } /////////////////////////PWM values are for the generic RGBW LED strips PWMvalue = map(level[i], 0, 1023, 0, 225); //PWMvalue = PWMvalue - scale; //this is a scaling factor to remove the noise floor. if(PWMvalue < 50){ PWMvalue=1; } if(LEDbin[i] == 0){ //27Hz - 140Hz , Peak is around 68Hz With a 50Hz or a 100Hz tone in the lab, this comes out as red and green combined. analogWrite(whitePin, PWMvalue-Wscale); delay(dLEDs1); ///used a variable so all delays in the RGBW strip can be changed at once } else if(LEDbin[i] == 1){ //96Hz - 160Hz, Peak is around 175Hz With a 140Hz tone in the lab, this comes out as red and green combined as well as white. analogWrite(redPin, PWMvalue-Rscale); analogWrite(bluePin, PWMvalue-Bscale); // I swapped the red and green pins here for a halloween setup delay(dLEDs1); } else if(LEDbin[i] == 2){ //167Hz - 400Hz, Peak is around 470Hz With a 200Hz tone in the lab, this comes out as White with a flickering green. A 400Hz tone gives a solid green analogWrite(bluePin, PWMvalue-Bscale); // I swapped the red and green pins here for a halloween setup delay(dLEDs1); } else if(LEDbin[i] == 3){ //417Hz - 1000Hz, Peak is around 1100Hz With a 500Hz tone in the lab, this comes out as solid White with a solid green. A 1000Hz tone gives a solid white analogWrite(redPin, PWMvalue-Rscale); delay(dLEDs1); } else if(LEDbin[i] == 4){ //1700 - 2500Hz, Peak is around 2700Hz With a 1900Hz tone in the lab, this comes out solid green. A 2400Hz tone gives a solid green analogWrite(greenPin, PWMvalue-Gscale); delay(dLEDs1); } else if(LEDbin[i] == 5){ //5000 - 6250Hz, Peak is around 9000Hz With a 6000Hz tone in the lab, this comes out solid blue. analogWrite(greenPin, PWMvalue-Gscale); analogWrite(redPin, PWMvalue-Rscale); // I swapped the blue and green pins here for a halloween setup delay(dLEDs1); } else if(LEDbin[i] == 6){ //12000 - 16000Hz, Peak is around 17000Hz With a 12000Hz tone in the lab, this comes out solid blue with a touch of green. A 16000Hz tone gives a solid green analogWrite(whitePin, PWMvalue-Wscale); delay(dLEDs1); } digitalWrite (strobePin, HIGH); delayMicroseconds (20); // Delay necessary due to timing diagram } ///////// You need to pick which bins are going to go with which lawn item, create the list here so they are all updated at the same time. /////////// // Strip One information stripA.fill(Argb, 0, xvalue[0]); stripA.fill(Argb, 101, xvalue[0]); stripA.fill(Argb, 201, xvalue[0]); stripA.fill(Arb, 0, xvalue[1]); stripA.fill(Arb, 101, xvalue[1]); stripA.fill(Arb, 201, xvalue[1]); stripA.fill(Ar, 0, xvalue[2]); stripA.fill(Ar, 101, xvalue[2]); stripA.fill(Ar, 20, xvalue[2]); stripA.show(); delay(dLEDs2); // ////// Strip 2 information ////// // stripC.fill(Cg, 0, wvalue[3]); // stripC.fill(Cg, 174, wvalue[3]); // stripC.fill(Crg, 0, wvalue[4]); // stripC.fill(Crg, 174, wvalue[4]); // stripC.fill(Cgb, 0, wvalue[5]); // stripC.fill(Cgb, 174, wvalue[5]); // stripC.show(); // delay(dLEDs2); /////////Strip 3 information //////// stripB.fill(Brb, 0, xvalue[3]); //Counting up stripB.fill(Bgb, 100, xvalue[4]); //Counting up stripB.fill(Bg, 200, xvalue[5]); //Counting up /////////// If you want strips lighting up from both ends and moving toward the middle, use the counting down from the far end // stripC.fill(Crb, 150-yvalue[6], yvalue[6]); //Counting down // stripC.fill(Cgb, 300-yvalue[4], yvalue[4]); // stripC.fill(Cg, 150-yvalue[3], yvalue[3]); // stripC.fill(Cg, 300-yvalue[3], yvalue[3]); // stripC.fill(Crb, 0, yvalue[4]); //Counting up // stripC.fill(Cgb, 150, yvalue[5]); //Counting up // stripC.fill(Cg, 0, yvalue[3]); //Counting up // stripC.fill(Cg, 150, yvalue[3]); //Counting up ////////// this tells the Microcontroller to write the code to the LED strips stripA.show(); //stripB.show(); //stripC.show(); //stripD.show(); //delay(dLEDs3); //use this if you need a pause at the end of the show command //////////////// This clears the strips to prepare for the next write command stripA.clear(); //stripB.clear(); //stripC.clear(); //stripD.clear(); // }