Missing data from Arduino's serial stored in array

Hi everyone,

I want to control wirelessly a neopixel stick (8 RGB leds WS2812). For this mission i´m using an arduino mega for Tx, an arduino uno for Rx and 2 transceiver NRF24l01. I’ve found this code for controlling through serial and works fine: https://create.arduino.cc/projecthub/code_files/154641/download

but when i modify the data storing process in order to send it by RF i’m losing data and the 3 last leds don’t work.

this is the original acquisition

FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, num_leds);
    // Loop through each of the pixels and read the values for each color
    do {
      while(!Serial.available());
        leds[cnt].r = Serial.read();
      while(!Serial.available());
        leds[cnt].g = Serial.read();
      while(!Serial.available());
        leds[cnt++].b = Serial.read();
      } 
    while(--num_leds);
    // Tell the FastLED Library it is time to update the strip of pixels
    FastLED.show();
    // WOO HOO... We are

So i divided this task between Tx and Rx. In the Tx i create an array for storing the data coming from serial:

transmitter code

#include <SPI.h>      
#include "nRF24L01.h" 
#include "RF24.h"

RF24 radio(9, 10);

// Definicion de las direcciones de comunicacion
const uint64_t direccion1 = 0x7878787878LL;
const uint64_t direccion2 = 0xB3B4B5B6F1LL;
bool TX_state = false;
int strip[24]



void setup() {
 
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  Serial.begin(115200); 
  radio.begin(); //Inicio del modulo nRF24L01+
  radio.setAutoAck(false);
  radio.setPALevel(RF24_PA_MAX);  
  radio.setDataRate(RF24_250KBPS); 
  radio.setChannel(100); 
  
  radio.openWritingPipe(direccion1);
  radio.openReadingPipe(1, direccion2);
  radio.stopListening();
  for(int i=0; i<24 ; i++){
  strip[0];
  }
  
}

void loop() {
  // Set some counter / temporary storage variables
  int cnt;
  unsigned int num_leds;
  unsigned int d1, d2, d3;


  for(;;) {
    
    cnt = 0;
    num_leds = 24;
    
    while(!Serial.available());
      if(Serial.read() != '>') {   //i'm using this header char in order for pointing the first element 
        continue;
        }                      
   
    
    do {
        while(!Serial.available());
        strip[cnt] = Serial.read();
        cnt++;
       } 
        while(num_leds--); 
  
       bool ok = radio.write(&strip, sizeof(strip)); 
        
        }

    }

receiver code

#include <SPI.h>      
#include "nRF24L01.h" 
#include "RF24.h"
#include <FastLED.h>

RF24 radio(9, 10);// CE y CSN 
#define NUM_LEDS 8
#define DATA_PIN 6
const int NUM_RG = 24;
CRGB leds[NUM_LEDS];
int strip [NUM_RG];
const uint64_t direccion1 = 0x7878787878LL;
const uint64_t direccion2 = 0xB3B4B5B6F1LL;


void setup(void)
{
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  Serial.begin(115200);
  radio.begin(); 
  radio.setAutoAck(false);
  radio.setPALevel(RF24_PA_MAX);  
  radio.setDataRate(RF24_250KBPS);
  radio.setChannel(100); 
  //Apertura de los canales de comunicacion
  radio.openWritingPipe(direccion2);
  radio.openReadingPipe(1, direccion1);
  radio.startListening(); 
} 

void loop(void)
{

 FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
 if (radio.available()) 
      {
      radio.read(&strip, sizeof(strip));
      }
    
  leds[7].setRGB(strip[0],strip[1],strip[2]);
  leds[6].setRGB(strip[3],strip[4],strip[5]);
  leds[5].setRGB(strip[6],strip[7],strip[8]);
  leds[4].setRGB(strip[9],strip[10],strip[11]);
  leds[3].setRGB(strip[12],strip[13],strip[14]);
  leds[2].setRGB(strip[15],strip[16],strip[17]);
  leds[1].setRGB(strip[18],strip[19],strip[20]);
  leds[0].setRGB(strip[21],strip[22],strip[23]);
  

  FastLED.show(); 
  
}

I can’t verify Tx by serial monitor what data was stored because vixen is using it, so i used serial monitor in RX and i noticed that not only i’m losing 3 leds last info but the header (">" = 62 in dec) it has been stored and sent :o . I think it’s loop race problem or serial buffer stuff. I appreciate a lot if you, wise and nice people, can help me :slight_smile: it would be awesome fix this and add more leds and make my life bright and less ignorant.