Millis() zu langsam

Dann misst Du Mist.
Ich habe es oben geschrieben warum.
Dir läuft die tatsächliche Zeit weg.
Und nur weil Dir die EchtZeit von Deiner Nano2Zeit wegläuft, oder anders gesagt: Nur weil Du den Nano2 künstlich ausbremst, funktioniert das, was Du da gebaut hast.

Spiel mal folgenden Sketch auf den Nano2 - Der korrigiert die Zeit.
Ich habe bei 23 Sekunden eine Abweichung von 30 ms - ABER Der geht nur so - jede Änderung macht eine Abweichung und den Rest wieder kaputt.

#include <Adafruit_NeoPixel.h>
#include "Arduino.h"

const byte stripes = 7;
const byte pins = 7, pin_wings1 = 13, pin_wings2 = 12, henryPin = 3, kleidPin = 5, kleidmotorBPin = 11 , kleidmotorAPin = 10, philPin = 6, aerialingePin = 9, nano1Pin = 2, nano3Pin = A3,
           CW = 1, CCW = 2, protectors = 1, gelb_rot = 1, blau_gelb = 2, blau_rot = 3, gelb_weiss = 4, rot_blau = 5, rot_gelb = 6, Colors = 6;
const byte ledPin[pins] = {3, 5, 6, 7, 9, 10, 11};
bool done [160], play = false;
const int shift = 300;
unsigned long lz_count = 0, bl_count = 0, sharp_count = 0;
enum effekts {fl_blink, fm_fl, fm_fr, fm_stp, fm_1, fm_2, fm_3, fm_4, fm_5, fm_1_5,
              fm_2_4, fm_all, c_fl, c_fr, c_stp, c_1, c_2, c_3, c_4, c_1_4,
              c_2_3, c_all, gf_stp, gf_1, gf_2, gf_all, spk_stp, start, stopp
             };
const byte brightness_wings = 40;
uint32_t colors;
const byte NUM_LEDS = 72;
int16_t blink_fc, blink_speed, blink_val, sharp_val, meteor_val, spk_val, rainbow_val, wing_color;
byte sparkles_value[NUM_LEDS];
bool sparkles_fade[NUM_LEDS];
bool sparkles_on;
bool sharp_on;
byte meteor_value[NUM_LEDS];
byte meteor_fo[NUM_LEDS];
byte meteor_on;
bool meteor_on_strip[stripes] = {0, 0, 0, 0, 0, 0, 0};
bool meteor_safe;
bool meteor_fade[NUM_LEDS];
unsigned long meteor_time[stripes] = {0, 0, 0, 0, 0, 0, 0};
unsigned long meteor_safe_time[stripes] = {0, 0, 0, 0, 0, 0, 0};
bool pixel[NUM_LEDS];
bool pixel2[NUM_LEDS];
const byte NUM_LEDs[] = {17, 10, 10, 10, 9, 8, 8};
const byte stripe[stripes][17] = {{0, 1, 2, 3, 4, 5, 6, 7, 16, 25, 26, 36, 37, 38, 49, 60, 61},
  {62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, 0, 0, 0, 0, 0},
  {50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0, 0, 0, 0, 0, 0, 0},
  {39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, 0, 0, 0},
  {27, 28, 29, 30, 31, 32, 33, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0},
  {17, 18, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0},
  {8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0}
};
const byte stripe_2[stripes][17] = {{0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 26, 27, 37, 38, 49, 50, 61},
  {62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 0, 0, 0, 0, 0, 0},
  {51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 0, 0, 0, 0, 0, 0, 0},
  {39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 0, 0, 0, 0, 0, 0, 0},
  {28, 29, 30, 31, 32, 33, 34, 35, 36, 0, 0, 0, 0, 0, 0, 0, 0},
  {18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 0, 0},
  {8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0}
};
const byte gamma_steps = 3;
const float gamma_blink [] {0, 255, 0, 0};
uint32_t zeit = 0;


Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, pin_wings1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip_2 = Adafruit_NeoPixel(NUM_LEDS, pin_wings2, NEO_GRB + NEO_KHZ800);

void setup()
{
  for (int i = 0; i < pins; i++)
  {
    pinMode(ledPin[i], OUTPUT);
  }
  pinMode(nano1Pin, INPUT);
  Serial.begin(115200);
  track_reset(0);
  wing_color = random(1, Colors);
  randomSeed(analogRead(6));
  strip.begin();
  strip.setBrightness(brightness_wings);
  strip.show();
  strip_2.begin();
  strip_2.setBrightness(brightness_wings);
  strip_2.show();
  // ab hier im Setup geändert
  pinMode(A3, OUTPUT);
  digitalWrite(A3, LOW);
}
uint32_t anzahl = 0;
uint32_t  startzeit = 0;
uint32_t stopzeit = 0;

extern volatile unsigned long timer0_millis;
void setMillis()
{
  static uint32_t zaehler = 0;
  unsigned long myMillis = 0;
  if (zaehler < 4)
  {
    myMillis = millis() + 2;
  }
  else
  {
    myMillis = millis() + 3;
    zaehler = 0;
  }
  byte sreg = SREG; // sichert das Statusregister
  cli(); // deaktiviert Interrupts (im Statusregister)
  timer0_millis = myMillis;  // setzt timer0 mit Übergabewert
  SREG = sreg; // Statusregister wieder zurückstellen
  sei();
  zaehler++;
}


void loop()
{
  anzahl++;
  if (anzahl == 1) startzeit = millis();
  if (anzahl > 5000)
  {
    digitalWrite(A3, LOW);
    stopzeit = millis();
    Serial.println(startzeit);
    Serial.println(stopzeit);
    Serial.println(stopzeit - startzeit);
    anzahl = 0;
  }
  //play = digitalRead(nano1Pin);
  play = true;
  // Ende der Änderungen
  strip.show();
  strip_2.show();
  strip.clear();
  strip_2.clear();
  //Serial.print(millis());
  //Serial.print(" ");
  //Serial.println(millis() - lz_count);
  setMillis();
  if (play)
  {
    digitalWrite(nano3Pin, HIGH);
    protect();
  }
  else
  {
    no_track();
    digitalWrite(nano3Pin, LOW);
    if (blink_val == 0 && sharp_val == 0) wing_color = random(1, Colors);
    lz_count = millis();
  }
  if (sharp_val > 0)sharpen(sharp_val, wing_color);
  for (byte i = 0; i < stripes; i++)
  {
    if (meteor_on_strip[i] || meteor_val > 0)
    {
      if (!meteor_safe)
      {
        meteor_safe = !meteor_safe;
        for (byte i = 0; i < stripes; i++)
        {
          meteor_time[i] = millis() - meteor_safe_time[i];
        }
      }
      meteor(meteor_val, 7);
    }
  }
  if (meteor_on == 0 && meteor_safe && meteor_val <= 0)
  {
    meteor_safe = !meteor_safe;
    for (byte i = 0; i < stripes; i++)
    {
      meteor_safe_time[i] = millis() - meteor_time[i];
    }
  }
  if (spk_val > 0)sparkles(spk_val);
  if (blink_val > 0) blink(blink_val, wing_color, 200);
  for (byte i = 0; i < NUM_LEDS; i++)
  {
    pixel[i] = false;
  }
}

void protect()
{
  if ((millis() - lz_count > 0 && millis() - lz_count < 91309)
      || (millis() - lz_count > 116070 && millis() - lz_count < 162234))
  {
    fade(blink_val, 0, 20);
  }
  else
  {
    fade(blink_val, 0, 10);
  }
  fade(blink_fc, 0, 0);
  if (millis() - lz_count > 12170 && millis() - lz_count < 161996)
  {
    fade(sharp_val, 0, 5);
  }
  else
  {
    fade(sharp_val, 0, 5);
  }
  if (millis() - lz_count > 2000 && millis() - lz_count < 10000)
  {
    fade(spk_val, 0, 0);
  }
  else
  {
    fade(spk_val, 0, 0);
  }
  if (millis() - lz_count > 91309 && millis() - lz_count < 116070)
  {
    fade(meteor_val, 180, 0);
  }
  else
  {
    fade(meteor_val, 0, 0);
  }
  henry(0);
  phil(0);
  aerial_inge(0);
  kleid(0);
  motor(0);
}
void no_track()
{
  fade(blink_fc, 140, 5);
  fade(blink_val, 0, 5);
  fade(sharp_val, 0, 2);
  fade(rainbow_val, 0, 5);
  fade(spk_val, 5, 0);
  fade(meteor_val, 0, 2);
  henry(1);
  phil(1);
  aerial_inge(1);
  kleid(1);
  motor(0);
}
void fade(int &var, byte wert, byte var_speed)
{
  if (var_speed > 0)
  {
    if (var < wert && millis() > bl_count )
    {
      var++;
      bl_count = millis() + var_speed;
    }
    if (var > wert && millis() > bl_count)
    {
      var--;
      bl_count = millis() + var_speed;
    }
  }
  else
  {
    var = wert;
  }
}
void henry(bool an)
{
  if (an) analogWrite(henryPin, random(127, 255));
  if (!an)digitalWrite(henryPin, LOW);
}
void kleid(bool an)
{
  if (an) analogWrite(kleidPin, random(127, 230));
  if (!an)digitalWrite(kleidPin, LOW);
}
void phil(bool an)
{
  if (an) analogWrite(philPin, random(127, 230));
  if (!an)digitalWrite(philPin, LOW);
}
void aerial_inge(bool an)
{
  if (an) analogWrite(aerialingePin, random(127, 255));
  if (!an)digitalWrite(aerialingePin, LOW);
}
void motor(bool an)
{
  static bool dir = true;
  static bool direct_change = true;
  static unsigned long motor_time;
  static int motor_runtime = 15000;
  if (an)
  {
    if (millis() < motor_time + motor_runtime)
    {
      digitalWrite(kleidmotorAPin, dir);
      digitalWrite(kleidmotorBPin, !dir);
      direct_change = true;
    }
    else
    {
      if (direct_change)
      {
        dir = !dir;
        direct_change = false;
        motor_runtime = random(12000, 24000);
        motor_time = millis() - 1000;
      }
      digitalWrite(kleidmotorAPin, LOW);
      digitalWrite(kleidmotorBPin, LOW);
    }
  }
  if (!an)
  {
    digitalWrite(kleidmotorAPin, LOW);
    digitalWrite(kleidmotorBPin, LOW);
  }
}
void track_reset(unsigned long p_reset)
{
  if (millis() - lz_count > p_reset)
  {
    play = false;
    Serial.println("Player reset");
    for (unsigned int i = 0; i < sizeof(done); i++)
    {
      done[i] = false;
    }
  }
}
//----------blink--------------------------
void blink(byte blink_intens, byte blink_color, byte speed_blink)
{
  static unsigned long blink_time;
  static byte Pixel;
  static byte blink_run;
  static float blinkred;
  static float blinkgreen;
  static float blinkblue;
  int bl_speed;
  float value = blink_intens;
  static byte blink_red, blink_green, blink_blue;
  blink_speed = speed_blink;
  if (blink_speed > 127) bl_speed = map(blink_speed, 128, 255, 150, 30);
  if (blink_speed <= 127) bl_speed = map(blink_speed, 0, 127, 30, 150);
  if (blink_color == 1 || blink_color == 4)
  {
    blink_red = 170;
    blink_green = 128;
    blink_blue = 0;
  }
  if (blink_color == 2 || blink_color == 3)
  {
    blink_red = 0;
    blink_green = 0;
    blink_blue = 170;
  }
  if (blink_color == 5 || blink_color == 6)
  {
    blink_red = 170;
    blink_green = 0;
    blink_blue = 0;
  }
  for (byte j = 0; j < stripes; j++)
  {
    byte fade = NUM_LEDs[j];
    //  if (fire_end > 0) fade = NUM_LEDs[j] - fire_end;
    for (byte i = 0; i <= fade; i++)
    {
      if (!pixel[stripe[j][NUM_LEDs[j] - i]])
      {
        blinkred = blink_red * (intensity(Pixel) / 255) * (value / 255);
        blinkgreen = blink_green * (intensity(Pixel) / 255) * (value / 255);
        blinkblue = blink_blue * (intensity(Pixel) / 255) * (value / 255);
        strip.setPixelColor(stripe[j][NUM_LEDs[j] - i], strip.Color(blinkred, blinkgreen, blinkblue));
        strip_2.setPixelColor(stripe_2[j][NUM_LEDs[j] - i], strip_2.Color(blinkred, blinkgreen, blinkblue));
      }
      Pixel == gamma_steps ? Pixel = 0 : Pixel++;
      pixel[stripe[j][NUM_LEDs[j] - i]] = true;
    }
  }
  if (blink_speed > 127)
  {
    if (blink_run <= gamma_steps)
    {
      if (millis() - bl_speed > blink_time)
      {
        blink_run ++;
        blink_time = millis();
      }
      Pixel = gamma_steps - blink_run;
    }
    else
    {
      blink_run = 0;
      Pixel = gamma_steps - blink_run;
    }
  }
  if (blink_speed <= 127)
  {
    if (blink_run > 0)
    {
      if (millis() - bl_speed > blink_time)
      {
        blink_run --;
        blink_time = millis();
      }
      Pixel = gamma_steps - blink_run;
    }
    else
    {
      blink_run = gamma_steps;
      Pixel = gamma_steps - blink_run;
    }
  }
}
float intensity(byte Pixel)
{
  static float value;
  value = gamma_blink[Pixel] > blink_fc ? gamma_blink[Pixel] : blink_fc;
  return value;
}
//----------rainbow---------------------
void rainbow()
{
  byte value = 200;
  int rgb_speed = -150;
  byte fade_in = NUM_LEDS;
  byte fade_out = 0;
  static uint32_t firstPixelHue = 0;
  static byte NUMLEDS;
  NUMLEDS = NUM_LEDS;
  for (unsigned int Pixel = fade_out; Pixel < fade_in; Pixel++)
  {
    int pixelHue = firstPixelHue + (Pixel * 65536L / NUMLEDS);
    strip.setPixelColor(Pixel, strip.gamma32(strip.ColorHSV(pixelHue, 255, value)));
    strip_2.setPixelColor(Pixel, strip_2.gamma32(strip_2.ColorHSV(pixelHue, 255, value)));
  }
  firstPixelHue += rgb_speed;
}
//----------sharpen--------------------------
void sharpen (byte sharp_intens, byte sharp_color)
{
  static byte sharp_red, sharp_green, sharp_blue;
  if (sharp_color == 1 || sharp_color == 3)
  {
    sharp_red = sharp_intens;
    sharp_green = 0;
    sharp_blue = 0;
  }
  if (sharp_color == 2 || sharp_color == 6)
  {
    sharp_red = sharp_intens;
    sharp_green = sharp_intens;
    sharp_blue = 0;
  }
  if (sharp_color == 5)
  {
    sharp_red = 0;
    sharp_green = 0;
    sharp_blue = sharp_intens;
  }
  if (sharp_color == 4)
  {
    sharp_red = sharp_intens;
    sharp_green = sharp_intens;
    sharp_blue = sharp_intens;
  }
  for (byte i = 1; i < stripes; i++)
  {
    if (!pixel[stripe[i][NUM_LEDs[i] - 1]]) strip.setPixelColor(stripe[i][NUM_LEDs[i] - 1], sharp_red, sharp_green, sharp_blue);
    if (!pixel[stripe[i][NUM_LEDs[i] - 1]]) strip_2.setPixelColor(stripe_2[i][NUM_LEDs[i] - 1], sharp_red, sharp_green, sharp_blue);
    pixel[stripe[i][NUM_LEDs[i] - 1]] = true;
  }
}
//----------sparkles--------------------------
void sparkles(byte sparkles_intens)
{
  static unsigned long sparkles_zeit;
  static unsigned long sparkles_fadetime;
  static unsigned long sparkles_start;
  byte fade_count = 0;
  byte Pixel = random(NUM_LEDS);
  int value = map(sparkles_intens, 1, 255, 500, 0);;
  byte value_fo = map(sparkles_intens, 1, 255, 6, 200);;
  if (millis() - value_fo > sparkles_fadetime)
  {
    for (byte Pixel_fade = 0; Pixel_fade < NUM_LEDS; Pixel_fade++)
    {
      byte pixelfade;
      pixelfade = sparkles_fadeout(Pixel_fade);
      if (sparkles_fade[Pixel_fade])
      {
        strip.setPixelColor(Pixel_fade, pixelfade, pixelfade, pixelfade);
        strip_2.setPixelColor(Pixel_fade, pixelfade, pixelfade, pixelfade);
      }
      fade_count += sparkles_fade[Pixel_fade];
    }
    if ((!pixel[Pixel]) && millis() - sparkles_zeit > sparkles_start)
    {
      strip.setPixelColor(Pixel, 0xffffff);
      sparkles_value[Pixel] = 255;
      pixel[Pixel] = true;
      sparkles_fade[Pixel] = true;
      sparkles_zeit = millis();
      sparkles_start = random(0, value);
    }
    sparkles_on = fade_count > 0 ? true : false;
    sparkles_fadetime = millis();
  }
  else
  {
    for (byte Pixel_fade = 0; Pixel_fade < NUM_LEDS; Pixel_fade++)
    {
      if (sparkles_fade[Pixel_fade])
      {
        strip.setPixelColor(Pixel_fade, sparkles_value[Pixel_fade], sparkles_value[Pixel_fade], sparkles_value[Pixel_fade]);
        strip_2.setPixelColor(Pixel_fade, sparkles_value[Pixel_fade], sparkles_value[Pixel_fade], sparkles_value[Pixel_fade]);
        pixel[Pixel_fade] = true;
      }
    }
  }
}
byte sparkles_fadeout(byte Pixel)
{
  if (sparkles_value[Pixel] > 12)
  {
    pixel[Pixel] = true;
    sparkles_value[Pixel] -= 12;
  }
  else
  {
    sparkles_value[Pixel] = 0;
    sparkles_fade[Pixel] = false;
  }
  return sparkles_value[Pixel];
}
//----------meteor---------------------
void meteor(byte speed_meteor, byte meteor_interval)
{
  static unsigned long meteor_time_on[] = {0, 500, 1200, 1600, 200, 2000, 800};
  static unsigned long meteor_fadetime;
  static byte meteor_incr[] = {0, 0, 0, 0, 0, 0, 0};
  static byte meteor_interval_safe;
  int fade_count[] = {0, 0, 0, 0, 0, 0, 0};
  static bool meteor_done[] = {0, 0, 0, 0, 0, 0, 0};
  byte meteor_speed = map(speed_meteor, 1, 255, 150, 5);
  //byte meteor_interval = map(dmx_value[17], 0, 255, 1, 10);
  if (millis() - (meteor_speed) > meteor_fadetime)
  {
    for ( byte i = 0; i < stripes; i++)
    {
      if (meteor_on_strip[i])
      {
        for (byte Pixel = 0; Pixel < NUM_LEDs[i]; Pixel++)
        {
          if (meteor_fade[stripe[i][Pixel]])
          {
            meteor_value[stripe[i][Pixel]] = meteor_fadeout(stripe[i][Pixel]);
            strip.setPixelColor(stripe[i][Pixel] , meteor_value[stripe[i][Pixel]], meteor_value[stripe[i][Pixel]], meteor_value[stripe[i][Pixel]]);
            strip_2.setPixelColor(stripe[i][Pixel] , meteor_value[stripe[i][Pixel]], meteor_value[stripe[i][Pixel]], meteor_value[stripe[i][Pixel]]);
          }
          fade_count[i] += meteor_fade[stripe[i][Pixel]];
        }
        if (!meteor_done[i])
        {
          strip.setPixelColor( stripe[i][meteor_incr[i]] , 0xfffff);
          strip_2.setPixelColor( stripe[i][meteor_incr[i]] , 0xfffff);
          if (meteor_incr[i] < NUM_LEDs[i])
          {
            pixel[stripe[i][meteor_incr[i]]] = true;
            meteor_fade[stripe[i][meteor_incr[i]]] = true;
            meteor_value[stripe[i][meteor_incr[i]]] = 255;
            meteor_fo[stripe[i][meteor_incr[i]]] = random(10, 150);
          }
        }
        if (meteor_incr[i] < NUM_LEDs[i] - 1)
        {
          meteor_incr[i] ++;
        }
        else
        {
          meteor_incr[i] = 0;
          meteor_done[i] = true;
          if (!fade_count[i])
          {
            meteor_time[i] = millis();
            meteor_time_on[i] = random(4000 / meteor_interval, 17000 / meteor_interval);
            meteor_done[i] = false;
            meteor_on_strip[i] = false;
            meteor_interval_safe = meteor_interval;
          }
        }
      }
      else
      {
        if (meteor_interval_safe != meteor_interval)
        {
          meteor_time[i] = millis();
          meteor_time_on[i] = random(4000 / meteor_interval, 17000 / meteor_interval);
          meteor_interval_safe = meteor_interval;
        }
      }
      if (millis() - meteor_time[i] > meteor_time_on[i])
      {
        meteor_on_strip[i] = true;
      }
      meteor_fadetime = millis();
    }
  }
  else
  {
    for (byte Pixel = 0; Pixel < NUM_LEDS; Pixel++)
    {
      if (meteor_fade[Pixel])
      {
        strip.setPixelColor(Pixel , meteor_value[Pixel], meteor_value[Pixel], meteor_value[Pixel]);
        strip_2.setPixelColor(Pixel , meteor_value[Pixel], meteor_value[Pixel], meteor_value[Pixel]);
        pixel[Pixel] = true;
      }
    }
  }
}
byte meteor_fadeout(byte Pixel)
{
  if (meteor_value[Pixel] > meteor_fo[Pixel])
  {
    pixel[Pixel] = true;
    meteor_value[Pixel] -= meteor_fo[Pixel];
  }
  else
  {
    meteor_value[Pixel] = 0;
    meteor_fade[Pixel] = false;
  }
  return meteor_value[Pixel];
}