Sinusoid mystery - Neopixel ring

Hello everyone,
I made a program (Arduino IDE) in February of this year (2024) to generate a light sinusoid as perfectly as possible. I used an Arduino UNO and a ring of 35 neopixel LEDs. The program is attached.

//LIGHT SIN by Caprario 

#include <Adafruit_NeoPixel.h>  //biblioteca do anel
#include <Math.h>

#define NUMLED 35                                                               //número de leds do anel
#define PIN 10                                                                  // pino controle do anel
#define LED 8                                                                   // pino controle led de referência
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMLED, PIN, NEO_GRB + NEO_KHZ800); // seta o anel

#define brilhopad 50 //brilho direto
byte brilhot[510];
byte bmax = 255;
byte bmin = 20;
byte delta = (bmax - bmin);
int id = int(delta) * 2;
//double periodo[] = { 8000, 4000, 3000, 2000, 1000, 750, 500 };
double periodo[] = { 4000 };  // digitar apenas o cliclo a ser ensaiado
float intervalo;
float a;
int NCICLOS = 10;
byte corR, corG, corB;

void setup() {
  Serial.begin(9600);
  pinMode(LED, OUTPUT);  // led de referência
  strip.begin();
  clearring();
}

void loop() {
  float tempo = 0;
  int lote = sizeof(periodo) / sizeof(double);  // tamanho da matriz de períodos
  // Seleção das cores
  corR = brilhopad;
  corG = brilhopad;
  corB = brilhopad;

  for (int k = 0; k < (lote); k++) {
    Serial.println("clique enter para começar");
    while (!Serial.available()) {
      // Aguarde até que haja dados disponíveis no buffer serial
    }
    // Limpe o buffer serial
    while (Serial.available()) {
      Serial.read();
    }
    Serial.print("****************   VAI COMEÇAR   ****************    ");
    Serial.println(periodo[k]);
    delay(2000);  // corrida para preparar o ensaio, ligar a camêra etc.



    intervalo = periodo[k] / (2 * float(delta));  // em milisegundos
    for (int i = 0; i < id; i++) {
      a = float(delta / 2);
      a = a * (sin((2 * PI * intervalo * float(i) / periodo[k]) + 1.5 * PI) + 1);
      a = a + bmin;
      brilhot[i] = byte(a);
    }
    intervalo = intervalo * 1000;  // em microsegundos
    clearring();
    delay(500);

    analogWrite(LED, 220);
    delay(15);  // tempo de led acesso infravermelho
    analogWrite(LED, 0);

    tempo = micros();

    for (int l = 0; l < NCICLOS; l++) {
      for (int j = 0; j < id; j++) {  // calculo do brilho para cada intervalo
        tempo = tempo + intervalo;
        while (micros() < tempo) {
          strip.setBrightness(brilhot[j]);
          for (int i = 0; i < NUMLED; i++) {
            strip.setPixelColor(i, strip.Color(corR, corG, corB));
          }
          strip.show();  // mostra o anel conforme programado
        }
      }
    }
    clearring();  //apaga o anel
  }
  //}
  Serial.println("c'est fini ");
  delay(100);
}

void clearring() {  //esta opção apaga o anel
  for (int i = 0; i < NUMLED; i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0));
  }
  strip.show();
}

I checked the result by making a video where the ring illuminates a white plane. Processing the image in Python OpenCV, the result is a beautiful sinusoid, almost perfect and with all cycles the same (Image 1).

However, I used the same program on the Arduino IDE at the end of April, and the sinusoid was distorted (Image 2). An intensity peak appears in the first cycle, in addition to noise at the peak of the other cycles.

I have already tried changing the ring, the Arduino board, the cables, with and without a power source, old versions of the program (which also worked), old versions of the Neopixel library, control pins (10,8,3), other computers and operating systems, I analyzed the images with other programs (Matlab), but the result remains the same, a distorted sinusoid with an intensity peak in the first cycle.

I still have not managed to solve this mystery.

Can anyone help me?

Any suggestions will be appreciated.

Thank you very much.