2 Octos with Teensy 3.2 Sync Help

Status
Not open for further replies.

RokGoblin

Active member
I have a project where I am about 2 weeks out from finishing and hitting a bit of a snag. I've never synced Octos before, and most of the threads here I see are using a matrix where I am using individual WS2813 strips.

I'm using some FastLED code I have currently with 8 strips and one Octo/Teensy3.2. The code is programmed so that each WS2813 strip is connected to a dedicated data pin on the Octo and I'm using all 8 pins on both Ethernet ports. I've added another Octo/Teensy combo to my new project doubling my LED strips and connected the sync ports, but I need some help on how to assign the other 8 strips in my code.

Code:
#define LED_DT1    2                                                               // Data pin to connect to the strip.
#define LED_DT2    14                                                               // Data pin to connect to the strip.
#define LED_DT3    7                                                               // Data pin to connect to the strip.
#define LED_DT4    8                                                               // Data pin to connect to the strip.
#define LED_DT5    6                                                               // Data pin to connect to the strip.
#define LED_DT6    20                                                               // Data pin to connect to the strip.
#define LED_DT7    21                                                               // Data pin to connect to the strip.
#define LED_DT8    5                                                                // Data pin to connect to the strip.

Above is how I am currently defining my existing 8 strips, so if I add the other 8 as follows, then how to I get the 2 boards to talk and know which board is answering to which LED_DT ##

Code:
#define LED_DT1    2                                                               // Data pin to connect to the strip. (Octo1)
#define LED_DT2    14                                                               // Data pin to connect to the strip. (Octo1)
#define LED_DT3    7                                                               // Data pin to connect to the strip. (Octo1)
#define LED_DT4    8                                                               // Data pin to connect to the strip. (Octo1)
#define LED_DT5    6                                                               // Data pin to connect to the strip. (Octo1)
#define LED_DT6    20                                                               // Data pin to connect to the strip. (Octo1)
#define LED_DT7    21                                                               // Data pin to connect to the strip. (Octo1)
#define LED_DT8    5                                                                // Data pin to connect to the strip. (Octo1)
#define LED_DT9    2                                                               // Data pin to connect to the strip. (Octo2)
#define LED_DT10    14                                                               // Data pin to connect to the strip. (Octo2)
#define LED_DT11    7                                                               // Data pin to connect to the strip. (Octo2)
#define LED_DT12    8                                                               // Data pin to connect to the strip. (Octo2)
#define LED_DT13    6                                                               // Data pin to connect to the strip. (Octo2)
#define LED_DT14    20                                                               // Data pin to connect to the strip. (Octo2)
#define LED_DT15    21                                                               // Data pin to connect to the strip. (Octo2)
#define LED_DT16    5                                                                // Data pin to connect to the strip. (Octo2)

This is basically similar to a modified "DemoReel" combined with another custom open source code project I worked on last year, and is is a continuation of that one with new easier to use and modify code I recently found. I'm admittedly not a coder and all this took me quite a while to wrap my head around, especially last summer when starting at zero.

I'm currently just displaying the exact same program output on each strip simultaneously, but I'd love to eventually be able to figure out how I can send one of 18 different programs to any of the strips or have just one or several strips at a time playing it's own program.

First things first tho, how the heck do I get this second board and the other 8 strips working LOL.
 
Some additional info...

16x WS2813 strips @5m 60 LED/m (150 pixels per strip)
This is NOT an array
All 16 strips (8 are working fine now on 1 Octo/Teensy) are currently outputting the same patterns simultaneously
I would love to eventually randomize this at the least or figure out how to output a specific pattern to a specific challel (i.e. DT1 and DT9 play the same while DT2 and DT10 play another, and the rest are dark etc. etc.)
5v power ground and data all supplied by one 15A 5v brick power supply, I have a 60A monster PS on standby
All power, data and ground transmitted on 30ft CAT5 patch cables to each strip (16x cables)

Here is an album of my old project from last year with my new mods to use RJ45 cables in place of the original long a$$ ribbon cables and the transition to my new design with added LED strips.

https://photos.app.goo.gl/6LxqCpJbQZu7rAQn7

I personally love the new design with a more modular approach, but I was hoping to do away with the screw terminal blocks for a spring terminal type (or whatever QD type) but I couldn't quite determine how to easily make it a bonded terminal block so I stayed with the old style screw terminals with the bar to bond all together. I haven't really looked around at others case and cabling designs and I started with the recommended Cableguard CG-500 box which ended up crammed full of wires and terminal blocks, but this year I am moving up to a much larger Pelican case which I am "in love" with at the moment.

I hope I can get some help here as I was assuming I just had to connect the 2 Octo boards together via a sync cable but then I realized each one uses the same pins and I had no idea how to re-use the same pins on the second board. I assume there is a definition of some kind of command I need to enter in the header to specify there are multiple Octo boards, but I have yet to locate this magical wizardry ;-)
 
I am also kinda wondering if I "designed" my DC power input "correctly", this was also a trial and error while thinking hard about signal flow. I am also not an electronics expert, but hell I did the whole previous design by the seat of my pants with no schematics, etc., just cobbling together parts from here and there (YouTube, Adafruit, etc.).

I currently still have one "net" left unconnected (blue dotted line), however if I am thinking correctly when I switch the power on, my "missing" leg will connect through the "re-settable" 15A fuse and provide me with proper fuse protection. Am I correct here in my rationalization or do I need to take an electronics 101 class? ;-) Should I go ahead and add some more circuitry to my power input? I would gladly accept any advice or recommendations here because as I said earlier, I am doing this by the seat of my pants and I am not an electrical engineer.

DC Power Control Circuit2.JPG
DC Power Control Circuit.JPG
 
Here is last years project in action...was using modified code from "StereoVU Meter v4" (I think). I changed the 2 channels to 8 channels with a ton of copy paste, edits in the code.

https://photos.app.goo.gl/HKPntL2oLu7jR5rS6

Last year was my first time working on an electronics project from scratch and also my first time attempting to edit and modify code like this. I only dabbled a tiny bit in HTML and XML previously and not even close to being a good programmer yet.

This year I'm using the "Soundmems_demo" with a few tweaks and attempting to create some of my own patterns, but I am way out of time to do that I think.
 
UPDATE: I have just brought all 16 strips online and they are workign but not in sync still even with the sync cable tied together.

One Octo board comes alive about 10 or so seconds after the second one and my patterns are out of sync
 
Am I approaching this wrong or something? Is going with 16 independent channels the wrong approach? It's much too late now for any design changes, but i'd love to get these 2 boards synced and then worry about the other more advanced programming later after this festival.

I said I was proud of my new design but I'm not an electrical designer and I'm not gonna be offended if someone had critical input.
 
without seeing code its hard to see what your doing to detect sync on the slave. In my mind the slave needs to be sure to detect a sync from the master and it uses this detection to fire off LED SHOW command. If you are to manipulate this signal method you can pretty much sync your LED SHOW and the same time.
 
without seeing code its hard to see what your doing to detect sync on the slave. In my mind the slave needs to be sure to detect a sync from the master and it uses this detection to fire off LED SHOW command. If you are to manipulate this signal method you can pretty much sync your LED SHOW and the same time.
Thanks!!!

I didn't realize there was code involved for detecting sync, but that makes sense and is what I was hoping to learn about here. I thought I just needed to solder a wire between the sync ports.

How do I tell FastLED I have another Octo to sync?

What do I need to define in my code to specify Octo1 as master and Octo2 as slave, or to define then at all?

How does the slave know its ports are not the same numbers as the master?

The pasted code in my O.P. is the only definitions I have for the LED strips .
 
Here is my code....I borrowed most of it from soundmems_demo and modified from only 1 strip to 16.

Code:
/* soundmems_demo

By: Andrew Tuline

Date: December 2017

Updated: September 2018


Now with FIFTEEN, YES, FIFTEEN 1D sound reactive routines. Some look similar to the others, so I've spread them out.

These sound reactive program does not use FFT or an MSGEQ7 chip, but rather just uses the current sample, the average (of the last 64 samples) and peak detection.


IMPORTANT NOTE:

The Sparkfun MEMS microphone I use SHOULD be powered with 3.3V. If you do so, you need to connect the 3.3V pin on the Arduino to the AREF pin on your Arduino.

Furthermore, you will need to uncommment the following line in setup:

//  analogReference(EXTERNAL);                                                    // Comment out this line for 3.3V Arduino's, ie. Flora, etc.

If you power your microphone from 5V or are using a 3.3V Arduino, such as a Flora, etc, then leave the line commented out.



Features:

- 10^h^h15, count 'em 10^h^h15 different awesome sound reactive display routines.
- Broken out functionality into separate .h files for readability.
- Only ONE delay statement in the setup. That's it. Delay statements have no place in the loop.
- Uses a variable rate EVERY_N_MILLISI() function instead.
- Trying to localize and tighten up the variable definitions as much as possible.
- Uses the 3.3V Sparkfun MEMS microphone with a whopping 67 dba gain.
- Uses a potentiometer to adjust sensitivity.
- Uses FastLED palettes, palette transitioning, beats, fading, fast math as well as perlin noise functionality.
- No floating point math. I use 8 or 16 bit for better performance.
- Shows that you don't need gobs of code to come up with a cool display sequence.


Not features:

- Not object oriented.
- Not passing variables or structs to/from functions.
- Sorry, but I prefer Java style curly brackets and not C style. Maybe that's because I don't use a real IDE and I'm not a real programmer.
- This probably won't scale beyond 255 LED's. I'll leave that job up to you.


Notes:

- This comes preconfigured for 60 APA102 LED's and a 3.3V Sparkfun MEMS microphone. Reconfigure and compile this for your own environment.
- Comment the analogreference(EXTERNAL) line if using a 3.3V Arduino OR a 5V microphone.
- This requires a potentiometer to adjust sensitivity. I use a linear 10K.
- This runs at about 430 loops per second on an Arduino Nano with 60 APA102's. If you add routines, do NOT add delay statements or I will find you, and . . .


*/
#include <OctoWS2811.h>

// Use qsuba for smooth pixel filtering and qsubd for digital pixel filtering.
#define qsubd(x, b)  ((x>b)?b:0)                                                // Digital unsigned subtraction macro. if result <0, then => 0. Otherwise, take on fixed value.
#define qsuba(x, b)  ((x>b)?x-b:0)                                              // Analog Unsigned subtraction macro. if result <0, then => 0. By Andrew Tuline.

#include "FastLED.h"                                                            // FastLED library.

#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif

// Fixed hardware and FastLED definitions cannot change on the fly.
//#define LED_DTXX    6
//    /*
#define LED_DT1    2                                                               // Data pin to connect to the strip.
#define LED_DT2    14                                                               // Data pin to connect to the strip.
#define LED_DT3    7                                                               // Data pin to connect to the strip.
#define LED_DT4    8                                                               // Data pin to connect to the strip.
#define LED_DT5    6                                                               // Data pin to connect to the strip.
#define LED_DT6    20                                                               // Data pin to connect to the strip.
#define LED_DT7    21                                                               // Data pin to connect to the strip.
#define LED_DT8    5                                                                // Data pin to connect to the strip.
#define LED_DT9    2                                                               // Data pin to connect to the strip.
#define LED_DT10    14                                                               // Data pin to connect to the strip.
#define LED_DT11    7                                                               // Data pin to connect to the strip.
#define LED_DT12    8                                                               // Data pin to connect to the strip.
#define LED_DT13    6                                                               // Data pin to connect to the strip.
#define LED_DT14    20                                                               // Data pin to connect to the strip.
#define LED_DT15    21                                                               // Data pin to connect to the strip.
#define LED_DT16    5                                                                // Data pin to connect to the strip.
//    */
//#define LED_CK 11                                                               // Clock pin for WS2801 or APA102.
#define COLOR_ORDER GRB                                                         // It's GRB for WS2812 and BGR for APA102.
#define LED_TYPE WS2813                                                         // Using APA102, WS2812, WS2801. Don't forget to modify LEDS.addLeds to suit.
#define NUM_LEDS 150                                                             // Number of LED's.

// Fixed sound hardware definitions cannot change on the fly.
#define MIC_PIN    A5                                                            // Microphone on A5.
#define POT_PIN    A4                                                            // Potentiometer on A4.

// Global FastLED variables
uint8_t max_bright = 255;                                                       // Maximum brightness, does change in other programs.
struct  CRGB leds[NUM_LEDS];                                                    // Initialize our LED array.


CRGBPalette16 currentPalette(PartyColors_p);
CRGBPalette16 targetPalette(PartyColors_p);
TBlendType    currentBlending = LINEARBLEND;                                    // NOBLEND or LINEARBLEND


// Global timer value
uint8_t timeval = 20;                                                           // Currently 'delay' value. No, I don't use delays, I use EVERY_N_MILLIS_I instead.
uint16_t loops = 0;                                                             // Our loops per second counter.

// Global sound variables used in other routines.
uint16_t oldsample = 0;                                                         // Previous sample is used for peak detection and for 'on the fly' values.
bool     samplepeak = 0;                                                        // The oldsample is well above the average, and is a 'peak'.
uint16_t sampleavg = 0;                                                         // Average of the last 64 samples.


// Global visual variables used in display and other routines.
bool thisdir = 0;                                                               // Used in a display routine as well as a support routine.



void setup() {

  delay(3000);                                                                  // A delay in case things don't work correctly. I use this for Pro Micro.

//  analogReference(EXTERNAL);                                                    // Comment out this line for 3.3V Arduino's, ie. Flora, etc.

//  LEDS.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);  // Use this for WS2801 or APA102
// LEDS.addLeds<LED_TYPE, LED_DTXX, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// Added a bunch of strips that are mirroring the output of the first strip
//    /*
 LEDS.addLeds<LED_TYPE, LED_DT1, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT2, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT3, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT4, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT5, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT6, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT7, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT8, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT9, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT10, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT11, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT12, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT13, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT14, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT15, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT16, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
//    */
  FastLED.setBrightness(max_bright);
  set_max_power_in_volts_and_milliamps(5, 500);                                 // FastLED Power management set at 5V, 500mA.

  Serial.begin(57600);                                                          // Serial port speed for debugging.

} // setup()



// Include various routines. Makes for an easier to read main program.

#include "soundmems.h"                                                          // Sample the sounds and provide a current sample, average of last 64 samples and boolean peak (for twinkles).

#include "support.h"                                                            // A few extra routines for good luck.

// Main sound reactive routines
#include "pixels.h"         // Long line of colours //G! brighter mostly lit bouncing colors cycling back and forth
#include "fillnoise.h"      // Center to edges with base color and twinkle  //G! mostly one color  cycling  with white raindrops both directions
#include "jugglep.h"        // Long line of sinewaves  //G! mellow and slow with white spots and rotating color fade
#include "ripple.h"         // Juggle with twinkles  //G! whit strobing with colored pulses  from the center outwards
#include "pixel.h"          // Long line of colours  //G! mostly lit entire strips with cycling wave from start to ends
#include "matrix.h"         // Start to end with twinkles  //G! matrix with white twinkles and color bars moving from start to end
#include "onesine.h"        // Long line of shortlines  //G! many short colors bars of about 6 or 7 LEDs with white strobing  back and forth
#include "noisefire.h"      // Start to end  //G! fire style VU meter with blank spaces growing from start to end
#include "rainbowbit.h"     // Long line of short lines with twinkles //G! rainbow span mid length with white sparkles start to end
#include "noisefiretest.h"  // Center to edges //G! fire VU meter growing from the center out
#include "rainbowg.h"       // Long line with flashes //G! full strip in solid color fading start to end wave in both directions and pulses
#include "noisewide.h"      // Center to edges  //G! full strip color noise or confetti from the cener outwards to start and end
#include "plasma.h"         // Long line of short lines  //G! mostly lit from center to ends with movement in both directions
#include "besin.h"          // center to edges with black  //G! Constantly pulsign and color changing from center outwards to start and ends
#include "noisepal.h"       // Long line  //G! Rotating color pallate with confetti from cener to outwards to start and end
#include "Gsine.h"          // G! First modification copied from onesine
#include "Gnoisefireshizz.h"          // G! First modification copied from onesine

// Test sound reactive routines



typedef void (*SimplePatternList[])();                                          // List of patterns to cycle through.  Each is defined as a separate function below.

//SimplePatternList gPatterns = {matrix};  //G! for testing a single pattern // HERE IS WHERE YOU ADD YOUR ROUTINE TO THE LIST!!!!
SimplePatternList gPatterns = {pixels, fillnoise, jugglep, ripple, pixel, matrix, onesine, noisefire, rainbowbit, noisefiretest, rainbowg, noisewide, plasma, besin, noisepal};  // HERE IS WHERE YOU ADD YOUR ROUTINE TO THE LIST!!!!

uint8_t gCurrentPatternNumber = 0;                                              // Index number of which pattern is current.



void loop() {                                                                   // The >>>>>>>>>> L-O-O-P <<<<<<<<<<<<<<<<<<<<<<<<<<<<  is buried way down here!!!11!1!

  soundmems();

//  showfps();                                                                  // Show the frames per second. It had better not dip too far.

  EVERY_N_MILLISECONDS(20) {  //G! originally 20ms
    uint8_t maxChanges = 24;
    nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges);      // Awesome palette blending capability.
  }

  EVERY_N_MILLIS_I(thisTimer,timeval) {
    thisTimer.setPeriod(timeval);                                               // We can change the timeval on the fly with this line, which is pretty sweet.
    gPatterns[gCurrentPatternNumber]();                                         // Call the current pattern function.
  }

  EVERY_N_SECONDS(5) {                                                          // Change the target palette to a 'related colours' palette every 5 seconds.
    uint8_t baseclr = random8();                                                // This is the base colour. Other colours are within 16 hues of this. One color is 128 + baseclr.

    targetPalette = CRGBPalette16(  CHSV(baseclr + random8(64), 255, random8(128,255)),
                                    CHSV(baseclr + random8(64), 255, random8(128,255)),
                                    CHSV(baseclr + random8(64), 192, random8(128,255)),
                                    CHSV(baseclr + random8(64), 255, random8(128,255)));
  }

  FastLED.show();                                                               // Send the 'leds' array out to the actual LED strip.

  EVERY_N_SECONDS(50) {                //G! originally 10ms                     // Change the current pattern function periodically.
    nextPattern();
  }

} // loop()



#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))                              // Kriegsman came up with this line. I knew what it did at one time. . Something, something make an array with enough room for the function names something. .



void nextPattern() {                                                            // Add one to the current pattern number, and wrap around at the end.

  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE(gPatterns);  // Another Kriegsman piece of magic.

} // nextPattern()
 
without seeing code its hard to see what your doing to detect sync on the slave...

Thanks again for attempting to help CREES. I am "finished" with my project for now and this coming weekend it will be unveiled.

I have 2 Octos/Teensys sending flashy lights to 16 strips so people will get to see fun stuff even if it's not exactly what I had envisioned.

If someone else eventually stumbles upon this thread and know how to do the syncing properly please hit me up. I am open to changing the code entirely or making drastic modifications after this weekend.

As I stated, I'm not really a coder or an electronics guy, but here is what I did using some "logic" and "signal flow" for my controller.

20190617_221947.jpg
20190618_234506.jpg
20190619_083013.jpg
 
Here that are setup in a pop up at a regional burn 2 weekends ago. They were stuck on a single program (pixels I think), but I got that worked out.
[video]https://photos.app.goo.gl/cVdyTWndxaHBLZi48[/video]
 
So I never got the issue with syncing my 2 OctoWS2811/Teensy3.2 combos resolved. To be clear I am not trying to send video or images, I am just sending color changing and dancing lights that react to the music.

I ended up posting my code just a few posts above if anyone can assist me please?

My problem is since the 2 boards are not synced the second boards 8 LED stips will output a different variation of the soundmems_demo. They seem to start OK, on the same program but then the variations in each program start to deviate. Is there a way to program both to use only the first Octo's CPU for the color pattern's etc. and not both independently?
20190907_005903.jpg

Here's a short video showing my issue.[video]https://photos.app.goo.gl/PAvv8UykcqQWYAr46[/video]

EDIT: I see now after re-reading the docs that the sync is intended to use when connected via USB, and this is a standalone system with no PC connected. Any ideas here?
 
Last edited:
Can someone please help me with some master/slave code for my Teensy boards in the code posted below. I've had some suggestions in another post to create 2 separate *.ino files for master and slave. I have tried to edit the code, split it into master and slave .ino files and add the following code (suggested by @KurtE in another thread I started).

I'm not sure how to make it work. I inserted it into my existing code where it seemed to make sense. you can see my //G! comments throughout which is where all of my edits to the original code are taking place.

Thanks for the ideas @KurtE


Master side, might do be setup to do something like:

Code:
void setup() {
    pinMode(12, OUTPUT);
    digitalWriteFast(12, HIGH);
 ...
}

void loop() {
   ... do everything to setup this next frame.
   digitalWriteFast(12, LOW);
   leds.show();  // do your output.
   digitalWriteFast(12, HIGH);
}

Slave side something like:
Code:
void setup() {
    pinMode(12, INPUT_PULLUP);
 ...
}

void loop() {
   ... do everything to setup this next frame.
    // wait for Sync signal
   while (!digitalReadFast(12)) ;
   leds.show();  // do your output.
}
Here is my edited "Master" code that doesn't seem to change anything with sync issues:

Code:
/* soundmems_demo

By: Andrew Tuline


Date: December 2017


Updated: September 2018




Now with FIFTEEN, YES, FIFTEEN 1D sound reactive routines. Some look similar to the others, so I've spread them out.


These sound reactive program does not use FFT or an MSGEQ7 chip, but rather just uses the current sample, the average (of the last 64 samples) and peak detection.




IMPORTANT NOTE:


The Sparkfun MEMS microphone I use SHOULD be powered with 3.3V. If you do so, you need to connect the 3.3V pin on the Arduino to the AREF pin on your Arduino.


Furthermore, you will need to uncommment the following line in setup:


//  analogReference(EXTERNAL);                                                    // Comment out this line for 3.3V Arduino's, ie. Flora, etc.


If you power your microphone from 5V or are using a 3.3V Arduino, such as a Flora, etc, then leave the line commented out.






Features:


- 10^h^h15, count 'em 10^h^h15 different awesome sound reactive display routines.
- Broken out functionality into separate .h files for readability.
- Only ONE delay statement in the setup. That's it. Delay statements have no place in the loop.
- Uses a variable rate EVERY_N_MILLISI() function instead.
- Trying to localize and tighten up the variable definitions as much as possible.
- Uses the 3.3V Sparkfun MEMS microphone with a whopping 67 dba gain.
- Uses a potentiometer to adjust sensitivity.
- Uses FastLED palettes, palette transitioning, beats, fading, fast math as well as perlin noise functionality.
- No floating point math. I use 8 or 16 bit for better performance.
- Shows that you don't need gobs of code to come up with a cool display sequence.




Not features:


- Not object oriented.
- Not passing variables or structs to/from functions.
- Sorry, but I prefer Java style curly brackets and not C style. Maybe that's because I don't use a real IDE and I'm not a real programmer.
- This probably won't scale beyond 255 LED's. I'll leave that job up to you.




Notes:


- This comes preconfigured for 60 APA102 LED's and a 3.3V Sparkfun MEMS microphone. Reconfigure and compile this for your own environment.
- Comment the analogreference(EXTERNAL) line if using a 3.3V Arduino OR a 5V microphone.
- This requires a potentiometer to adjust sensitivity. I use a linear 10K.
- This runs at about 430 loops per second on an Arduino Nano with 60 APA102's. If you add routines, do NOT add delay statements or I will find you, and . . .




*/
#include <OctoWS2811.h>


// Use qsuba for smooth pixel filtering and qsubd for digital pixel filtering.
#define qsubd(x, b)  ((x>b)?b:0)                                                // Digital unsigned subtraction macro. if result <0, then => 0. Otherwise, take on fixed value.
#define qsuba(x, b)  ((x>b)?x-b:0)                                              // Analog Unsigned subtraction macro. if result <0, then => 0. By Andrew Tuline.


#include <FastLED.h>                                                            // FastLED library.


#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif


// Fixed hardware and FastLED definitions cannot change on the fly.
//#define LED_DTXX    6


#define LED_DT1    2                                                               // Data pin to connect to the strip.
#define LED_DT2    14                                                               // Data pin to connect to the strip.
#define LED_DT3    7                                                               // Data pin to connect to the strip.
#define LED_DT4    8                                                               // Data pin to connect to the strip.
#define LED_DT5    6                                                               // Data pin to connect to the strip.
#define LED_DT6    20                                                               // Data pin to connect to the strip.
#define LED_DT7    21                                                               // Data pin to connect to the strip.
#define LED_DT8    5                                                                // Data pin to connect to the strip.
    /*
#define LED_DT9    2                                                               // Data pin to connect to the strip.
#define LED_DT10    14                                                               // Data pin to connect to the strip.
#define LED_DT11    7                                                               // Data pin to connect to the strip.
#define LED_DT12    8                                                               // Data pin to connect to the strip.
#define LED_DT13    6                                                               // Data pin to connect to the strip.
#define LED_DT14    20                                                               // Data pin to connect to the strip.
#define LED_DT15    21                                                               // Data pin to connect to the strip.
#define LED_DT16    5                                                                // Data pin to connect to the strip.
//    */
//#define LED_CK 11                                                               // Clock pin for WS2801 or APA102.
#define COLOR_ORDER GRB                                                         // It's GRB for WS2812 and BGR for APA102.
#define LED_TYPE WS2813                                                         // Using APA102, WS2812, WS2801. Don't forget to modify LEDS.addLeds to suit.
#define NUM_LEDS 150                                                             // Number of LED's.


// Fixed sound hardware definitions cannot change on the fly.
#define MIC_PIN    A5                                                            // Microphone on A5. (19)
#define POT_PIN    A4                                                            // Potentiometer on A4. (18)
//#define BUT_PIN   A3                                                            // Button on A3. (17)


// Global FastLED variables
uint8_t max_bright = 255;                                                       // Maximum brightness, does change in other programs.
struct  CRGB leds[NUM_LEDS];                                                    // Initialize our LED array.




CRGBPalette16 currentPalette(PartyColors_p);
CRGBPalette16 targetPalette(PartyColors_p);
TBlendType    currentBlending = LINEARBLEND;                                    // NOBLEND or LINEARBLEND




// Global timer value
uint8_t timeval = 20;                                                           // Currently 'delay' value. No, I don't use delays, I use EVERY_N_MILLIS_I instead.
uint16_t loops = 0;                                                             // Our loops per second counter.


// Global sound variables used in other routines.
uint16_t oldsample = 0;                                                         // Previous sample is used for peak detection and for 'on the fly' values.
bool     samplepeak = 0;                                                        // The oldsample is well above the average, and is a 'peak'.
uint16_t sampleavg = 0;                                                         // Average of the last 64 samples.




// Global visual variables used in display and other routines.
bool thisdir = 0;                                                               // Used in a display routine as well as a support routine.






void setup() {
    pinMode(12, OUTPUT);  //G! added suggestion from KurtE
    digitalWriteFast(12, HIGH);  //G! added suggestion from KurtE 
    
  delay(3000);                                                                  // A delay in case things don't work correctly. I use this for Pro Micro.


//  analogReference(EXTERNAL);                                                    // Comment out this line for 3.3V Arduino's, ie. Flora, etc.


//  LEDS.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);  // Use this for WS2801 or APA102
// LEDS.addLeds<LED_TYPE, LED_DTXX, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// Added a bunch of strips that are mirroring the output of the first strip
//    /*
 LEDS.addLeds<LED_TYPE, LED_DT1, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT2, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT3, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT4, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT5, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT6, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT7, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT8, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
    /*
 LEDS.addLeds<LED_TYPE, LED_DT9, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT10, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT11, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT12, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT13, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT14, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT15, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT16, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
    */
  FastLED.setBrightness(max_bright);
  set_max_power_in_volts_and_milliamps(5, 1300);                                 // G! Originally 5, 500 // FastLED Power management set at 5V, 500mA.


  Serial.begin(57600);                                                          // Serial port speed for debugging.


} // setup()






// Include various routines. Makes for an easier to read main program.


#include "soundmems.h"                                                          // Sample the sounds and provide a current sample, average of last 64 samples and boolean peak (for twinkles).


#include "support.h"                                                            // A few extra routines for good luck.


// Main sound reactive routines
#include "pixels.h"         // Long line of colours //G! brighter mostly lit bouncing colors cycling back and forth
#include "fillnoise.h"      // Center to edges with base color and twinkle  //G! mostly one color  cycling  with white raindrops both directions
#include "jugglep.h"        // Long line of sinewaves  //G! mellow and slow with white spots and rotating color fade
#include "ripple.h"         // Juggle with twinkles  //G! whit strobing with colored pulses  from the center outwards
#include "pixel.h"          // Long line of colours  //G! mostly lit entire strips with cycling wave from start to ends
#include "matrix.h"         // Start to end with twinkles  //G! matrix with white twinkles and color bars moving from start to end
#include "onesine.h"        // Long line of shortlines  //G! many short colors bars of about 6 or 7 LEDs with white strobing  back and forth
#include "noisefire.h"      // Start to end  //G! fire style VU meter with blank spaces growing from start to end
#include "rainbowbit.h"     // Long line of short lines with twinkles //G! rainbow span mid length with white sparkles start to end
#include "noisefiretest.h"  // Center to edges //G! fire VU meter growing from the center out
#include "rainbowg.h"       // Long line with flashes //G! full strip in solid color fading start to end wave in both directions and pulses
#include "noisewide.h"      // Center to edges  //G! full strip color noise or confetti from the cener outwards to start and end
#include "plasma.h"         // Long line of short lines  //G! mostly lit from center to ends with movement in both directions
#include "besin.h"          // center to edges with black  //G! Constantly pulsign and color changing from center outwards to start and ends
#include "noisepal.h"       // Long line  //G! Rotating color pallate with confetti from cener to outwards to start and end
// Additional routines added by G!
#include "Gsine.h"          // G! First modification copied from onesine
#include "Gnoisefireshizz.h"          // G! First modification copied from noisefiretest


// Test sound reactive routines






typedef void (*SimplePatternList[])();                                          // List of patterns to cycle through.  Each is defined as a separate function below.


SimplePatternList gPatterns = {Gsine};  //G! for testing a single pattern // HERE IS WHERE YOU ADD YOUR ROUTINE TO THE LIST!!!!
//SimplePatternList gPatterns = {Gsine, pixels, fillnoise, jugglep, ripple, pixel, matrix, onesine, noisefire, rainbowbit, noisefiretest, rainbowg, noisewide, plasma, besin, noisepal};  // HERE IS WHERE YOU ADD YOUR ROUTINE TO THE LIST!!!!


uint8_t gCurrentPatternNumber = 0;                                              // Index number of which pattern is current.






void loop() {                                                                   // The >>>>>>>>>> L-O-O-P <<<<<<<<<<<<<<<<<<<<<<<<<<<<  is buried way down here!!!11!1!


  soundmems();


//  showfps();                                                                  // Show the frames per second. It had better not dip too far.


  EVERY_N_MILLISECONDS(20) {  //G! originally 20ms
    uint8_t maxChanges = 24;
    nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges);      // Awesome palette blending capability.
  }


  EVERY_N_MILLIS_I(thisTimer,timeval) {
    thisTimer.setPeriod(timeval);                                               // We can change the timeval on the fly with this line, which is pretty sweet.
    gPatterns[gCurrentPatternNumber]();                                         // Call the current pattern function.
  }


  EVERY_N_SECONDS(5) {                                                          // Change the target palette to a 'related colours' palette every 5 seconds.
    uint8_t baseclr = random8();                                                // This is the base colour. Other colours are within 16 hues of this. One color is 128 + baseclr.


    targetPalette = CRGBPalette16(  CHSV(baseclr + random8(64), 255, random8(128,255)),
                                    CHSV(baseclr + random8(64), 255, random8(128,255)),
                                    CHSV(baseclr + random8(64), 192, random8(128,255)),
                                    CHSV(baseclr + random8(64), 255, random8(128,255)));
  }
   digitalWriteFast(12, LOW);  //G! added suggestion from KurtE 
//   leds.show();  // do your output.  //G! added suggestion from KurtE 


  FastLED.show();                                                               // Send the 'leds' array out to the actual LED strip.


  EVERY_N_SECONDS(30) {                //G! originally 10 sec                     // Change the current pattern function periodically.
    nextPattern();
  }
   digitalWriteFast(12, HIGH);  //G! added suggestion from KurtE 
} // loop()






#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))                              // Kriegsman came up with this line. I knew what it did at one time. . Something, something make an array with enough room for the function names something. .






void nextPattern() {                                                            // Add one to the current pattern number, and wrap around at the end.


  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE(gPatterns);  // Another Kriegsman piece of magic.


} // nextPattern()


And here's the edited "Slave" code for the 2nd Octo/Teensy (and theoretically 3rd, 4th, etc.):
Code:
/* soundmems_demo

By: Andrew Tuline


Date: December 2017


Updated: September 2018




Now with FIFTEEN, YES, FIFTEEN 1D sound reactive routines. Some look similar to the others, so I've spread them out.


These sound reactive program does not use FFT or an MSGEQ7 chip, but rather just uses the current sample, the average (of the last 64 samples) and peak detection.




IMPORTANT NOTE:


The Sparkfun MEMS microphone I use SHOULD be powered with 3.3V. If you do so, you need to connect the 3.3V pin on the Arduino to the AREF pin on your Arduino.


Furthermore, you will need to uncommment the following line in setup:


//  analogReference(EXTERNAL);                                                    // Comment out this line for 3.3V Arduino's, ie. Flora, etc.


If you power your microphone from 5V or are using a 3.3V Arduino, such as a Flora, etc, then leave the line commented out.






Features:


- 10^h^h15, count 'em 10^h^h15 different awesome sound reactive display routines.
- Broken out functionality into separate .h files for readability.
- Only ONE delay statement in the setup. That's it. Delay statements have no place in the loop.
- Uses a variable rate EVERY_N_MILLISI() function instead.
- Trying to localize and tighten up the variable definitions as much as possible.
- Uses the 3.3V Sparkfun MEMS microphone with a whopping 67 dba gain.
- Uses a potentiometer to adjust sensitivity.
- Uses FastLED palettes, palette transitioning, beats, fading, fast math as well as perlin noise functionality.
- No floating point math. I use 8 or 16 bit for better performance.
- Shows that you don't need gobs of code to come up with a cool display sequence.




Not features:


- Not object oriented.
- Not passing variables or structs to/from functions.
- Sorry, but I prefer Java style curly brackets and not C style. Maybe that's because I don't use a real IDE and I'm not a real programmer.
- This probably won't scale beyond 255 LED's. I'll leave that job up to you.




Notes:


- This comes preconfigured for 60 APA102 LED's and a 3.3V Sparkfun MEMS microphone. Reconfigure and compile this for your own environment.
- Comment the analogreference(EXTERNAL) line if using a 3.3V Arduino OR a 5V microphone.
- This requires a potentiometer to adjust sensitivity. I use a linear 10K.
- This runs at about 430 loops per second on an Arduino Nano with 60 APA102's. If you add routines, do NOT add delay statements or I will find you, and . . .




*/
#include <OctoWS2811.h>


// Use qsuba for smooth pixel filtering and qsubd for digital pixel filtering.
#define qsubd(x, b)  ((x>b)?b:0)                                                // Digital unsigned subtraction macro. if result <0, then => 0. Otherwise, take on fixed value.
#define qsuba(x, b)  ((x>b)?x-b:0)                                              // Analog Unsigned subtraction macro. if result <0, then => 0. By Andrew Tuline.


#include <FastLED.h>                                                            // FastLED library.


#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif


// Fixed hardware and FastLED definitions cannot change on the fly.
//#define LED_DTXX    6


#define LED_DT1    2                                                               // Data pin to connect to the strip.
#define LED_DT2    14                                                               // Data pin to connect to the strip.
#define LED_DT3    7                                                               // Data pin to connect to the strip.
#define LED_DT4    8                                                               // Data pin to connect to the strip.
#define LED_DT5    6                                                               // Data pin to connect to the strip.
#define LED_DT6    20                                                               // Data pin to connect to the strip.
#define LED_DT7    21                                                               // Data pin to connect to the strip.
#define LED_DT8    5                                                                // Data pin to connect to the strip.


#define LED_DT9    2                                                               // Data pin to connect to the strip.
#define LED_DT10    14                                                               // Data pin to connect to the strip.
#define LED_DT11    7                                                               // Data pin to connect to the strip.
#define LED_DT12    8                                                               // Data pin to connect to the strip.
#define LED_DT13    6                                                               // Data pin to connect to the strip.
#define LED_DT14    20                                                               // Data pin to connect to the strip.
#define LED_DT15    21                                                               // Data pin to connect to the strip.
#define LED_DT16    5                                                                // Data pin to connect to the strip.




//#define LED_CK 11                                                               // Clock pin for WS2801 or APA102.
#define COLOR_ORDER GRB                                                         // It's GRB for WS2812 and BGR for APA102.
#define LED_TYPE WS2813                                                         // Using APA102, WS2812, WS2801. Don't forget to modify LEDS.addLeds to suit.
#define NUM_LEDS 150                                                             // Number of LED's.


// Fixed sound hardware definitions cannot change on the fly.
#define MIC_PIN    A5                                                            // Microphone on A5. (19)
#define POT_PIN    A4                                                            // Potentiometer on A4. (18)
//#define BUT_PIN    A3                                                            // Button on A3. (17)


// Global FastLED variables
uint8_t max_bright = 255;                                                       // Maximum brightness, does change in other programs.
struct  CRGB leds[NUM_LEDS];                                                    // Initialize our LED array.




CRGBPalette16 currentPalette(PartyColors_p);
CRGBPalette16 targetPalette(PartyColors_p);
TBlendType    currentBlending = LINEARBLEND;                                    // NOBLEND or LINEARBLEND




// Global timer value
uint8_t timeval = 20;                                                           // Currently 'delay' value. No, I don't use delays, I use EVERY_N_MILLIS_I instead.
uint16_t loops = 0;                                                             // Our loops per second counter.


// Global sound variables used in other routines.
uint16_t oldsample = 0;                                                         // Previous sample is used for peak detection and for 'on the fly' values.
bool     samplepeak = 0;                                                        // The oldsample is well above the average, and is a 'peak'.
uint16_t sampleavg = 0;                                                         // Average of the last 64 samples.




// Global visual variables used in display and other routines.
bool thisdir = 0;                                                               // Used in a display routine as well as a support routine.


void setup() {
    pinMode(12, INPUT_PULLUP);  //G! added suggestion from KurtE


  delay(3000);                                                                  // A delay in case things don't work correctly. I use this for Pro Micro.


//  analogReference(EXTERNAL);                                                    // Comment out this line for 3.3V Arduino's, ie. Flora, etc.


//  LEDS.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);  // Use this for WS2801 or APA102
// LEDS.addLeds<LED_TYPE, LED_DTXX, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// Added a bunch of strips that are mirroring the output of the first strip
    /*
 LEDS.addLeds<LED_TYPE, LED_DT1, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT2, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT3, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT4, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT5, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT6, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT7, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT8, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
*/


 LEDS.addLeds<LED_TYPE, LED_DT9, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT10, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT11, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT12, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT13, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT14, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT15, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812
 LEDS.addLeds<LED_TYPE, LED_DT16, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);          // Use this for WS2812


  FastLED.setBrightness(max_bright);
  set_max_power_in_volts_and_milliamps(5, 1300);                                 // G! Originally 5, 500 // FastLED Power management set at 5V, 500mA.


  Serial.begin(57600);                                                          // Serial port speed for debugging.


} // setup()






// Include various routines. Makes for an easier to read main program.


#include "soundmems.h"                                                          // Sample the sounds and provide a current sample, average of last 64 samples and boolean peak (for twinkles).


#include "support.h"                                                            // A few extra routines for good luck.


// Main sound reactive routines
#include "pixels.h"         // Long line of colours //G! brighter mostly lit bouncing colors cycling back and forth
#include "fillnoise.h"      // Center to edges with base color and twinkle  //G! mostly one color  cycling  with white raindrops both directions
#include "jugglep.h"        // Long line of sinewaves  //G! mellow and slow with white spots and rotating color fade
#include "ripple.h"         // Juggle with twinkles  //G! whit strobing with colored pulses  from the center outwards
#include "pixel.h"          // Long line of colours  //G! mostly lit entire strips with cycling wave from start to ends
#include "matrix.h"         // Start to end with twinkles  //G! matrix with white twinkles and color bars moving from start to end
#include "onesine.h"        // Long line of shortlines  //G! many short colors bars of about 6 or 7 LEDs with white strobing  back and forth
#include "noisefire.h"      // Start to end  //G! fire style VU meter with blank spaces growing from start to end
#include "rainbowbit.h"     // Long line of short lines with twinkles //G! rainbow span mid length with white sparkles start to end
#include "noisefiretest.h"  // Center to edges //G! fire VU meter growing from the center out
#include "rainbowg.h"       // Long line with flashes //G! full strip in solid color fading start to end wave in both directions and pulses
#include "noisewide.h"      // Center to edges  //G! full strip color noise or confetti from the cener outwards to start and end
#include "plasma.h"         // Long line of short lines  //G! mostly lit from center to ends with movement in both directions
#include "besin.h"          // center to edges with black  //G! Constantly pulsign and color changing from center outwards to start and ends
#include "noisepal.h"       // Long line  //G! Rotating color pallate with confetti from cener to outwards to start and end
// Additional routines added by G!
#include "Gsine.h"          // G! First modification copied from onesine
#include "Gnoisefireshizz.h"          // G! First modification copied from noisefiretest


// Test sound reactive routines






typedef void (*SimplePatternList[])();                                          // List of patterns to cycle through.  Each is defined as a separate function below.


SimplePatternList gPatterns = {Gsine};  //G! for testing a single pattern // HERE IS WHERE YOU ADD YOUR ROUTINE TO THE LIST!!!!
//SimplePatternList gPatterns = {Gsine, pixels, fillnoise, jugglep, ripple, pixel, matrix, onesine, noisefire, rainbowbit, noisefiretest, rainbowg, noisewide, plasma, besin, noisepal};  // HERE IS WHERE YOU ADD YOUR ROUTINE TO THE LIST!!!!


uint8_t gCurrentPatternNumber = 0;                                              // Index number of which pattern is current.






void loop() {                                                                   // The >>>>>>>>>> L-O-O-P <<<<<<<<<<<<<<<<<<<<<<<<<<<<  is buried way down here!!!11!1!


  soundmems();


//  showfps();                                                                  // Show the frames per second. It had better not dip too far.


  EVERY_N_MILLISECONDS(20) {  //G! originally 20ms
    uint8_t maxChanges = 24;
    nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges);      // Awesome palette blending capability.
  }


  EVERY_N_MILLIS_I(thisTimer,timeval) {
    thisTimer.setPeriod(timeval);                                               // We can change the timeval on the fly with this line, which is pretty sweet.
    gPatterns[gCurrentPatternNumber]();                                         // Call the current pattern function.
  }


  EVERY_N_SECONDS(5) {                                                          // Change the target palette to a 'related colours' palette every 5 seconds.
    uint8_t baseclr = random8();                                                // This is the base colour. Other colours are within 16 hues of this. One color is 128 + baseclr.


    targetPalette = CRGBPalette16(  CHSV(baseclr + random8(64), 255, random8(128,255)),
                                    CHSV(baseclr + random8(64), 255, random8(128,255)),
                                    CHSV(baseclr + random8(64), 192, random8(128,255)),
                                    CHSV(baseclr + random8(64), 255, random8(128,255)));
  }


// wait for Sync signal  //G! added suggestion from KurtE
   while (!digitalReadFast(12)) ;  //G! added suggestion from KurtE 
//   leds.show();  // do your output.  //G! added suggestion from KurtE 


  FastLED.show();                                                               // Send the 'leds' array out to the actual LED strip.


  EVERY_N_SECONDS(30) {                //G! originally 10 sec                     // Change the current pattern function periodically.
    nextPattern();
  }




} // loop()






#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))                              // Kriegsman came up with this line. I knew what it did at one time. . Something, something make an array with enough room for the function names something. .






void nextPattern() {                                                            // Add one to the current pattern number, and wrap around at the end.


  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE(gPatterns);  // Another Kriegsman piece of magic.


} // nextPattern()
 
without seeing code its hard to see what your doing to detect sync on the slave. In my mind the slave needs to be sure to detect a sync from the master and it uses this detection to fire off LED SHOW command. If you are to manipulate this signal method you can pretty much sync your LED SHOW and the same time.
Any chance you could please take a look at the code now that I posted it?
 
Still having trouble?

Any chance you could please take a look at the code now that I posted it?

RokGoblin,

I know this is a bit old, but I just stumbled across it looking for similar info. Are you still having sync issues? I saw how you kept asking for assistance, but were getting no response, so I looked into it and I think you can find more info on what you are looking for here: https://www.pjrc.com/teensy/td_libs_OctoWS2811.html#videodisplay

It's not yet clear to me which parts of that info are specific to the VideoDisplay project and which would apply directly to your situation, but the info is there. I will be looking into this more and experimenting in the near future, but wanted to give you something to go on for now since you have been waiting so long for help. Also, you might want to consider using the videodisplay project in a future iteration of your project. I really like the effects you are getting with the LED strips even when all displaying identically, but videodisplay could be a good way to get some other interesting effects involving different patterns on different strings. Fast transitions and some anti-aliasing could allow the perception of 'objects' or 'orbs of light' that would otherwise be too large for a single strip.
I know you said that you are not necessarily a programmer, so if you have any specific questions, let me know, because I am ;)

-frd1963
 
Wow, thanks for looking into this further. I had also started looking at the VideoDisplay option a while back for a different presentation. I think I was just misunderstanding the purpose of the sync feature initially, as it seems to be intended for the Video Display feature as you discovered.

I also realized the way I was doing things, sending the same code down each strip via software, was very redundant and I could have more easily achieved the same effect by splitting the signal 8x and injecting power at each strip via hardware.

I will keep playing with the VideoDisplay and pixel mapping for a different experience, but I still want to get the other concept figured out.
 
Status
Not open for further replies.
Back
Top