How to combine millis LED program and accelerometer triggered sound program?

// First LED program
#include <Adafruit_NeoPixel.h>

/*  Digital pins for LEDs   */
//#define PIN1
#define PIN2 16 // 
//#define PIN3
//#define PIN4
#define PIN5 13 //

// How many NeoPixels?
#define NUMPIXELS 14

Adafruit_NeoPixel pixels2(NUMPIXELS, PIN2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels5(NUMPIXELS, PIN5, NEO_GRB + NEO_KHZ800);

unsigned long startMillis2 = millis();  // timestamp
unsigned long startMillis5 = millis();
unsigned long now2;
unsigned long now5;
int i = 0;  // iterator, from for-loop
int k = 0;
bool latch2 = false;
bool latch5 = false;

const int period = 200;


int x5_a, y5_a;
int x5_b, y5_b;

int x2_a, y2_a;
int x2_b, y2_b;


void setup()
{
  pixels2.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  pixels5.begin();
}

void loop()
{


  //first strand, activate if touched

  now2 = millis();

  if (  /*abs(x5_a) > 15 || abs(y5_a) > 15*/  )
    latch2 = true;

  if (latch2 == true)
  {
    if (now2 - startMillis2 >= period)
    {
      startMillis2 = now2;  // save timestamp

      if (i >= NUMPIXELS)
      {
        i = 0; // reset i at max value
        pixels2.clear(); // Set all pixel colors to 'off'
        latch2 = false;
      }

      pixels2.setPixelColor( i, pixels2.Color(150 - i * 20, i * 20, 0) );

      pixels2.show();   // Send the updated pixel colors to the hardware

      i++;  // go to next value
    }
  }

  //second strand, activate if touched

  now5 = millis();

  if (  /*abs(x2_a) > 45 || abs(y2_a) > 12*/  )
    latch5 = true;

  if (latch5 == true)
  {
    if (now5 - startMillis5 >= period)
    {
      startMillis5 = now5;  // save timestamp

      if (k >= NUMPIXELS)
      {
        k = 0; // reset i at max value
        pixels5.clear();
        latch5 = false;

      }

      pixels5.setPixelColor( k, pixels5.Color(150 - k * 20, k * 20, 0) );

      pixels5.show();

      k++;  // go to next value
    }
  }




}

I would like to combine these two programs.


  ESP32

  https://www.mouser.com/ProductDetail/Espressif-Systems/ESP32-DevKitC-32D

  Pinout

  ESP   SparkFun Shield
  GND   GND (jumper all grounds together for Shield)
  16    2
  17    3
  4     4
  RX    RX
  TX    TX

  5V    +5V
  3V3   3.3V

*/

#include <Adafruit_NeoPixel.h>


#define RXD2 16 // was 2, not needed
#define TXD2 18 // was 3 MIDI-In

/*  Digital pins for LEDs   */
//#define PIN1
#define PIN2 16 // 
//#define PIN3
//#define PIN4
#define PIN5 13 //


// How many NeoPixels?
#define NUMPIXELS 14


Adafruit_NeoPixel pixels2(NUMPIXELS, PIN2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels5(NUMPIXELS, PIN5, NEO_GRB + NEO_KHZ800);

unsigned long startMillis2 = millis();  // timestamp
unsigned long startMillis5 = millis();
unsigned long now2;
unsigned long now5;
int i = 0;  // iterator, from for-loop
int k = 0;
bool latch2 = false;
bool latch5 = false;

const int period = 200;




byte note = 0; //The MIDI note value to be played
byte resetMIDI = 4; //Reset line
int  instrument = 0;



byte x5pin = 12;
byte y5pin = 14;

//byte x4pin = 26;
//byte y4pin = 25;

//byte x3pin = 35;
//byte y3pin = 34;

byte x2pin = 4;
byte y2pin = 0;

//byte x1pin = 2;
//byte y1pin = 15;



int x5_a, y5_a;
int x5_b, y5_b;

int x2_a, y2_a;
int x2_b, y2_b;


void setup()
{
  Serial.begin(115200);

  //Setup soft serial for MIDI control
  Serial2.begin(31250, SERIAL_8N1, RXD2, TXD2);


  pixels2.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  pixels5.begin();


  //Reset
  pinMode(resetMIDI, OUTPUT);
  digitalWrite(resetMIDI, LOW);
  delay(100);
  digitalWrite(resetMIDI, HIGH);
  delay(100);
  talkMIDI(0xB0, 0x07, 120); //0xB0 is channel message, set channel volume to near max (127)
}


void loop()
{
  x5_a = analogRead(x5pin);
  y5_a = analogRead(y5pin);
  delay(10);
  x5_b = analogRead(x5pin);
  y5_b = analogRead(y5pin);

  x5_a = x5_b - x5_a;
  y5_a = y5_b - y5_a;




  x2_a = analogRead(x2pin);
  y2_a = analogRead(y2pin);
  delay(10);
  x2_b = analogRead(x2pin);
  y2_b = analogRead(y2pin);

  x2_a = x2_b - x2_a;
  y2_a = y2_b - y2_a;



  if (abs(x5_a) > 15 || abs(y5_a) > 15)
  {
    //      Serial.print("x5: ");
    //      Serial.print(x5_a, DEC);    // acceleration in X axis
    //      Serial.println();
    //      Serial.print("y5: ");
    //      Serial.print(y5_a, DEC);    // acceleration in Y axis
    //      Serial.println('\n');

    talkMIDI(0xB0, 0, 0x00); //Default bank GM1
    talkMIDI(0xC0, 98, 0);   //Set instrument number. 0xC0 is a 1 data byte command

    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0, 98, 60);
    delay(50);

    //Turn off the note with a given off/release velocity
    noteOff(0, 98, 15000);








  }




  if (abs(x2_a) > 45 || abs(y2_a) > 12)
  {
    //      Serial.print("x5: ");
    //      Serial.print(x2_a, DEC);    // acceleration in X axis
    //      Serial.println();
    //      Serial.print("y5: ");
    //      Serial.print(y2_a, DEC);    // acceleration in Y axis
    //      Serial.println('\n');

    talkMIDI(0xB0, 0, 0x00); //Default bank GM1
    talkMIDI(0xC0, 98, 0);   //Set instrument number. 0xC0 is a 1 data byte command

    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0, 98, 60);
    delay(50);

    //Turn off the note with a given off/release velocity
    noteOff(0, 98, 15000);






  }

  delay(100);



}








//Send a MIDI note-on message.  Like pressing a piano key
//channel ranges from 0-15
void noteOn(byte channel, byte note, byte attack_velocity) {
  talkMIDI( (0x90 | channel), note, attack_velocity);
}

//Send a MIDI note-off message.  Like releasing a piano key
void noteOff(byte channel, byte note, byte release_velocity) {
  talkMIDI( (0x80 | channel), note, release_velocity);
}

//Plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that data values are less than 127
void talkMIDI(byte cmd, byte data1, byte data2) {
  Serial2.write(cmd);
  Serial2.write(data1);

  //Some commands only have one data byte. All cmds less than 0xBn have 2 data bytes
  //(sort of: http://253.ccarh.org/handout/midiprotocol/)
  if ( (cmd & 0xF0) <= 0xB0)
    Serial2.write(data2);

}

You will notice all programs:

  1. Load the hardware configuration.
  2. Configure the hardware.
  3. Exercise the hardware.

Identify this pattern in your two sketches. Combine #1 and #2, then use separate functions for each device to combine #3.

i guess you're blindly trying to replicate code for 2 NeoPixel devices by cut&paste. i see compiler errors that should have been addressed

in particular, the condition expression is commented out in the above

i don't see where the value of x5_a is set, other than its initialized value of zero and so see no reason why the condition will ever be true and the code conditional on latch2 ever executing

it would make sense to understand the code for a single device and get it working before attempting to duplicate it for a 2nd device

Yes, that was written with touch sensors which I took out. I didn't want to confuse everyone. The touch sensors were just a test. Instead, it should be motion (accelerometers). Both separate programs compile in their original form.

I will get the LED working with just accelerometers (not touch sensors). But I didn't think that auxiliary program was really needed...



#include <Adafruit_NeoPixel.h>

#define RXD2 16 // was 2, not needed
#define TXD2 18 // was 3 MIDI-In

/*  Digital pins for LEDs   */
//#define PIN1
#define PIN2 16 // 
//#define PIN3
//#define PIN4
#define PIN5 13 //


// How many NeoPixels?
#define NUMPIXELS 14


Adafruit_NeoPixel pixels2(NUMPIXELS, PIN2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels5(NUMPIXELS, PIN5, NEO_GRB + NEO_KHZ800);

unsigned long startMillis2 = millis();  // timestamp
unsigned long startMillis5 = millis();
unsigned long now2;
unsigned long now5;
int i = 0;  // iterator, from for-loop
int k = 0;
bool latch2 = false;
bool latch5 = false;

const int period = 200;




byte note = 0; //The MIDI note value to be played
byte resetMIDI = 4; //Reset line
int  instrument = 0;



byte x5pin = 12;
byte y5pin = 14;

byte x4pin = 26;
byte y4pin = 25;

byte x3pin = 35;
byte y3pin = 34;

byte x2pin = 4;
byte y2pin = 0;

byte x1pin = 2;
byte y1pin = 15;



int x5_a, y5_a;
int x5_b, y5_b;

int x2_a, y2_a;
int x2_b, y2_b;


void setup()
{
  Serial.begin(115200);

  pixels2.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  pixels5.begin();
}

void loop()
{
  x5_a = analogRead(x5pin);
  y5_a = analogRead(y5pin);
  delay(10);
  x5_b = analogRead(x5pin);
  y5_b = analogRead(y5pin);

  x5_a = x5_b - x5_a;
  y5_a = y5_b - y5_a;



  x2_a = analogRead(x2pin);
  y2_a = analogRead(y2pin);
  delay(10);
  x2_b = analogRead(x2pin);
  y2_b = analogRead(y2pin);

  x2_a = x2_b - x2_a;
  y2_a = y2_b - y2_a;

  
  // first strand, activate if MOVED

  now2 = millis();

  if (abs(x2_a) > 50 || abs(y2_a) > 50)
    latch2 = true;

  if (latch2 == true)
  {
    //      Serial.print(x2_a, DEC);    // acceleration in X axis
    //      Serial.println();
          Serial.print("y5: ");
          Serial.print(y2_a, DEC);    // acceleration in Y axis
          Serial.println('\n');



    
    if (now2 - startMillis2 >= period)
    {
      startMillis2 = now2;  // save timestamp

      if (i >= NUMPIXELS)
      {
        i = 0; // reset i at max value
        pixels2.clear(); // Set all pixel colors to 'off'
        latch2 = false;
      }

      pixels2.setPixelColor( i, pixels2.Color(150 - i * 20, i * 20, 0) );

      pixels2.show();   // Send the updated pixel colors to the hardware

      i++;  // go to next value
    }
  }

  // second strand, activate if MOVED

  now5 = millis();

  if (abs(x5_a) > 50 || abs(y5_a) > 50)
    latch5 = true;

  if (latch5 == true)
  {

//          Serial.print("x5: ");
//          Serial.print(x5_a, DEC);    // acceleration in X axis
//          Serial.println('\n');
          Serial.print("y5: ");
          Serial.print(y5_a, DEC);    // acceleration in Y axis
          Serial.println('\n');
        
    if (now5 - startMillis5 >= period)
    {
      startMillis5 = now5;  // save timestamp

      if (k >= NUMPIXELS)
      {
        k = 0; // reset i at max value
        pixels5.clear();
        latch5 = false;

      }

      pixels5.setPixelColor( k, pixels5.Color(150 - k * 20, k * 20, 0) );

      pixels5.show();

      k++;  // go to next value
    }
  }




}

Here it is.

unsigned long  startmillisLED2  = millis();
unsigned long  startmillisACC2  = millis();
unsigned long  nowLED2;
unsigned long  nowACC2;

unsigned long  startmillisLED5  = millis();
unsigned long  startmillisACC5  = millis();
unsigned long  nowLED5;
unsigned long  nowACC5;

const int periodLED = 200;
const int periodNoteOn = 50;
const int periodBetwNote = 100;

Will the variables for the motion/accelerometer and LEDs look this this?

not sure

  • because you're doing copy&paste, you're duplicating variables which is awkward

  • i see you added 'k' instead of duplicating 'i'

  • it seems there are extra unused variables: x4pin, x3pin, x1pin

  • now2 and now5 are redundant. suggest a common local variable at top of loop()

    unsigned long msec = millis ();
  • while i know the following works, i don't think it's appropriate, nor what you really want.
unsigned long  startmillisLED5  = millis();

why not just leave it initialized by default to zero?

  • don't see a need for latch2/5. why not
    if (abs(x2_a) > 50 || abs(y2_a) > 50) {
        //      Serial.print(x2_a, DEC); 
  • reading variables twice is unnecessary.

capture the last value each iteration and used it during the next to determined any changes

  int x = analogRead(x5pin);
  int y = analogRead(y5pin);

  if (abs(x - xLst) > 50 || abs(y - yLst) > 50) {
    ...
  }
  xLst = x;
  yLst = y;

a common approach to duplicating such things is to create a class or struct that captures all the variables for each thing (object). another approach is to use arrays for each variable

I'm trying to give you the minimal code. There are actually five total (five LED strings, five accelerometers). I took out 1, 3, 4.

How else is the LED string supposed to stop? It don't see how to stop it from going on forever once triggered.

How does that add a 10 ms delay between readings?

sorry. i overlooked that latch is only cleared after i reaches NUMPIXELS

i assumed making a measurement each loop iteration would be sufficiently long. if you really want each measurement to be at least 10 msec apart, put a single delay(10) at the bottom of loop()

a lotta copy&paste

look this over

#define MyHW
#ifdef MyHW
# include "sim.hh"

#else
# include <Adafruit_NeoPixel.h>
#endif

#define NUMPIXELS 14
Adafruit_NeoPixel pixels0 (NUMPIXELS, 2, NEO_GRB+NEO_KHZ800);
Adafruit_NeoPixel pixels1 (NUMPIXELS, 3, NEO_GRB+NEO_KHZ800);
Adafruit_NeoPixel pixels2 (NUMPIXELS, 4, NEO_GRB+NEO_KHZ800);
Adafruit_NeoPixel pixels3 (NUMPIXELS, 5, NEO_GRB+NEO_KHZ800);

const byte PinX [] = { A1, A2, A3, A4 };
const byte PinY [] = {  6,  7,  8,  9 };
const int N = sizeof(PinX);

int           xLst [N];
int           yLst [N];
int           i    [N];
unsigned long msecLst [N];


const unsigned long Period = 200;
      unsigned long msec;

char s [80];

// -----------------------------------------------------------------------------
void setup ()
{
    Serial.begin (115200);
    Serial.println ("Neo");

    for (int n = 0; n < N; n++)  {
        xLst [n] = analogRead (PinX [n]);
        yLst [n] = analogRead (PinY [n]);
    }

    pixels0.begin ();
    pixels1.begin ();
    pixels2.begin ();
    pixels3.begin ();
}

// -----------------------------------------------------------------------------
void update (
    int  n,
    Adafruit_NeoPixel * pixels )
{
    int x = analogRead (PinX [n]);
    int y = analogRead (PinY [n]);

#if 0
        sprintf (s, " %6d %6d", x, y);
        Serial.println (s);
#endif

    if (abs (x - xLst [n]) > 50 || abs (y - yLst [n]) > 50) {
        if (msec - msecLst [n] >= Period) {
            msecLst [n] = msec;

            sprintf (s, " pinX %2d, i %3d, x %4d, y %4d",
                PinX [n], i [n], x, y);
            Serial.println (s);

            if (i [n] >= NUMPIXELS) {
                i [n] = 0; // reset i at max value
                pixels->clear (); // Set all pixel colors to 'off'
            }

            pixels->setPixelColor (i [n],
                            pixels->Color (150 - i [n]*20, i [n]*20, 0));
            pixels->show ();
            i [n]++;
        }
    }

    xLst [n] = x;
    yLst [n] = y;
}

// -----------------------------------------------------------------------------
void loop ()
{
    msec = millis ();

    update (0, & pixels0);
    update (1, & pixels1);
    update (2, & pixels2);
    update (3, & pixels3);
}

That's a nice way of organizing the Input pins, Processing variables, and Outputs into arrays so you can cycle through the repetitive code. It makes it easier to focus on the process.

Thank you very much. Clean. It is a little hard to understand, but I will look more into how it works exactly.

What about the other part? integrating the audio sound that triggers with the LED trigger?

    talkMIDI(0xB0, 0, 0x00); //Default bank GM1
    talkMIDI(0xC0, 98, 0);   //Set instrument number. 0xC0 is a 1 data byte command

    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0, 98, 60);
    delay(50);

    //Turn off the note with a given off/release velocity
    noteOff(0, 98, 15000);

  delay(100);

the code very basic. what do you find hard to understand?

i don't know how these talkMIDI things are intended to be used. is there just one associated with each pixels?

Because I'm used to copy/paste types of programs. I'll understand it eventually. I've just haven't used arrays and pointers much.

I believe there is just one talkMIDI pair that selects the instrument:

  talkMIDI(0xB0, 0, 0x00); //Default bank GM1
  talkMIDI(0xC0, 98, 0);   //Set instrument number. 0xC0 is a 1 data byte command

Then each string of neopixels would be individually triggered and emit a note:

      //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
      noteOn(0, 98, 60);
      delay(50);

      //Turn off the note with a given off/release velocity
      noteOff(0, 98, 15000);
/*

  ESP32

  https://www.mouser.com/ProductDetail/Espressif-Systems/ESP32-DevKitC-32D

  Pinout

  ESP   SparkFun Shield
  GND   GND (jumper all grounds together for Shield)
  16    2
  17    3
  4     4
  RX    RX
  TX    TX

  5V    +5V
  3V3   3.3V

*/

#include <Adafruit_NeoPixel.h>

#define RXD2 16 // was 2, not needed
#define TXD2 18 // was 3 MIDI-In

/*  Digital pins for LEDs   */
#define PIN0 22 // don't use, actually D1 - GPIO8, retrace other pin on PCB
#define PIN1 16 // JP2
#define PIN2 33 // JP3
#define PIN3 27 // JP4
#define PIN4 13 // JP5

//#define note 0 //The MIDI note value to be played
//#define resetMIDI 4 //Reset line
//#define instrument 0


#define NUMPIXELS 14
Adafruit_NeoPixel pixels0 (NUMPIXELS, PIN0, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels1 (NUMPIXELS, PIN1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels2 (NUMPIXELS, PIN2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels3 (NUMPIXELS, PIN3, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels4 (NUMPIXELS, PIN4, NEO_GRB + NEO_KHZ800);


byte note = 0; //The MIDI note value to be played
byte resetMIDI = 4; //Reset line
int  instrument = 0;

//    X    Y
// 1: 2,   15
// 2: 4,   0
// 3: 35,  34
// 4: 26,  25
// 5: 12,  14
const byte PinX [] = { 2, 4, 35, 26, 12 };
const byte PinY [] = { 15, 0, 34, 25, 14 };
const int N = sizeof(PinX);

int           xLast [N];
int           yLast [N];
int           i     [N];
unsigned long msecLast [N];


const unsigned long PeriodLED = 200;
const unsigned long PeriodBEL = 50;
unsigned long msec;

char s [80];

// -----------------------------------------------------------------------------
void setup ()
{
  Serial.begin (115200);

  //Setup soft serial for MIDI control
  Serial2.begin(31250, SERIAL_8N1, RXD2, TXD2);

  for (int n = 0; n < N; n++)
  {
    xLast [n] = analogRead (PinX [n]);
    yLast [n] = analogRead (PinY [n]);
  }

  pixels0.begin ();
  pixels1.begin ();
  pixels2.begin ();
  pixels3.begin ();
  pixels4.begin ();

  //Reset
  pinMode(resetMIDI, OUTPUT);
  digitalWrite(resetMIDI, LOW);
  delay(100);
  digitalWrite(resetMIDI, HIGH);
  delay(100);
  talkMIDI(0xB0, 0x07, 120); //0xB0 is channel message, set channel volume to near max (127)
}



// -----------------------------------------------------------------------------

//Send a MIDI note-on message.  Like pressing a piano key
//channel ranges from 0-15
void noteOn(byte channel, byte note, byte attack_velocity) {
  talkMIDI( (0x90 | channel), note, attack_velocity);
}

//Send a MIDI note-off message.  Like releasing a piano key
void noteOff(byte channel, byte note, byte release_velocity) {
  talkMIDI( (0x80 | channel), note, release_velocity);
}

//Plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that data values are less than 127
void talkMIDI(byte cmd, byte data1, byte data2) {
  Serial2.write(cmd);
  Serial2.write(data1);

  //Some commands only have one data byte. All cmds less than 0xBn have 2 data bytes
  //(sort of: http://253.ccarh.org/handout/midiprotocol/)
  if ( (cmd & 0xF0) <= 0xB0)
    Serial2.write(data2);

}

// -----------------------------------------------------------------------------
void update ( int  n,  Adafruit_NeoPixel * pixels )
{
  int x = analogRead (PinX [n]);
  int y = analogRead (PinY [n]);

#if 0
  sprintf (s, " %6d %6d", x, y);
  Serial.println (s);
#endif

  talkMIDI(0xB0, 0, 0x00); //Default bank GM1
  talkMIDI(0xC0, 98, 0);   //Set instrument number. 0xC0 is a 1 data byte command

  if (abs (x - xLast [n]) > 45 || abs (y - yLast [n]) > 45)
  {
    msecLast [n] = msec;
    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0, 98, 60);

    if (msec - msecLast [n] >= PeriodBEL)
    {
      //Turn off the note with a given off/release velocity
      noteOff(0, 98, 15000);
    }

    if (msec - msecLast [n] >= PeriodLED)
    {
      msecLast [n] = msec;

      sprintf (s, " pinX %2d, i %3d, x %4d, y %4d",
               PinX [n], i [n], x, y);
      Serial.println (s);

      if (i [n] >= NUMPIXELS)
      {
        i [n] = 0; // reset i at max value
        pixels->clear (); // Set all pixel colors to 'off'
      }

      pixels->setPixelColor (i [n],
                             pixels->Color (150 - i [n] * 20, i [n] * 20, 0));
      pixels->show ();
      i [n]++;
    }
  }

  xLast [n] = x;
  yLast [n] = y;
}

// -----------------------------------------------------------------------------
void loop ()
{
  msec = millis ();

  update (0, & pixels0);
  update (1, & pixels1);
  update (2, & pixels2);
  update (3, & pixels3);
  update (4, & pixels4);

}

Maybe something like that? I don't get any sound or light, but I will try to see if the previous LED/light program worked with my setup...

not clear how they work, what is the difference between the 2 you've posted, what are the arguments?

you say "note" (i assume some tone), should they emit this "note" while the pixel string is active or a different note for each pixel color?

this suggests a different approach.

currently, each pixel string would sequence thru a NUMPIXEL colors before checking the next string.

i assume you would like all strings to possibly be sequencing at the same time. this suggests using a time that advances the color (?) on each active string as long as that string is active (i.e. latch).

is the correct?

Yes. That is the point of using millis instead of keeping it how it is with delay. It works with delay. Each LED strand does not work simultaneously though.

I am not seeing anything in the serial monitor...

Just a question regarding your sketch from post 17:

#define RXD2 16 // was 2, not needed
#define TXD2 18 // was 3 MIDI-In

/*  Digital pins for LEDs   */
#define PIN0 22 // don't use, actually D1 - GPIO8, retrace other pin on PCB
#define PIN1 16 // JP2
#define PIN2 33 // JP3
#define PIN3 27 // JP4
#define PIN4 13 // JP5

You seem to be using pin 16 for Serial2 (RXD2) as well as for pixels1 (PIN1) ...

Good catch. I need to retrace some pins. I'll just move it to pin 23 for the time being. Only strands 2, 3 and 4 will work (not 0 and 1).