Horloge Géante

le code actuel est

#include <DS3232RTC.h>
#include <Time.h>
#include <Wire.h>
#include "FastLED.h"
#define NUM_LEDS 114 // Number of LED controls (remember I have 3 leds / controler
#define COLOR_ORDER BRG  // Define color order for your strip
#define DATA_PIN 6  // Data pin for led comunication
#define BP_START 7 // Pin bouton Start
#define BP_STOP   8 // Pin bouton Stop
#define BP_RESET 9 // Pin bouton Reset
#define INTER 10   // Pin inter 15 / 45

CRGB leds[NUM_LEDS]; // Define LEDs strip
byte digits[10][28] = {
  {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, //0
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0}, //1
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0}, //2
  {1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0}, //3
  {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1}, //4
  {1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}, //5
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}, //6
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0}, //7
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, //8
  {1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, //9 | 2D Array for numbers on 7 segment
};
bool Dot = true;  //Dot state
int ledColor = 0x0000FF; // Color used (in hex)
int Heure = 0;
bool EtatChrono = false;  // Chrono arrêté
int HeureMax = 4500;

void setup() {
  Serial.begin(9600);
  //  Wire.begin();
  LEDS.addLeds<WS2811, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); // Set LED strip type
  LEDS.setBrightness(255); // Set initial brightness
  pinMode(BP_START, INPUT_PULLUP); // bouton START
  pinMode(BP_STOP, INPUT_PULLUP); // bouton STOP
  pinMode(BP_RESET, INPUT_PULLUP); // bouton RESET
  pinMode(INTER, INPUT_PULLUP); // inter 15 / 45
  TimeToArray();
  FastLED.show();

}

// Check Light sensor and set brightness accordingly
void BrightnessCheck() {
  const byte sensorPin = 3; // light sensor pin
  const byte brightnessLow = 5; // Low brightness value
  const byte brightnessHigh = 255; // High brightness value
  int sensorValue = digitalRead(sensorPin); // Read sensor
  if (sensorValue == 0) {
    LEDS.setBrightness(brightnessHigh);
  }
  else {
    LEDS.setBrightness(brightnessLow);
  }
}

// Convert time to array needet for display
void TimeToArray() {
  int cursor = 0;
  int Secondes = Heure % 100;
  int Now = Heure;

  Dot = true;
  if (Secondes % 2 == 1) Dot = false;
  if (Dot) {
    leds[56] = ledColor;
    leds[57] = ledColor;
  }
  else {
    leds[56] = 0x000000;
    leds[57] = 0x000000;
  }

  for (int i = 1; i <= 4; i++) {
    int digit = Now % 10; // get last digit in time
    if (i == 1) {
            Serial.print("Digit 4 is : ");Serial.print(digit);Serial.print(" ");
      cursor = 0;
      for (int k = 0; k <= 27; k++) {
                Serial.print(digits[digit][k]);
        leds[cursor + k] = ledColor * digits[digit][k];
        cursor ++;
      }
            Serial.println();
    }
    else if (i == 2) {
            Serial.print("Digit 3 is : ");Serial.print(digit);Serial.print(" ");
      cursor = 28;
      for (int k = 0; k <= 27; k++) {
                Serial.print(digits[digit][k]);
        leds[cursor + k] = ledColor * digits[digit][k];
        cursor ++;
      }
            Serial.println();
    }
    else if (i == 3) {
            Serial.print("Digit 2 is : ");Serial.print(digit);Serial.print(" ");
      cursor = 58;
      for (int k = 0; k <= 27; k++) {
                Serial.print(digits[digit][k]);
        leds[cursor + k] = ledColor * digits[digit][k];
        cursor ++;
      }
            Serial.println();
    }
    else if (i == 4) {
            Serial.print("Digit 1 is : ");Serial.print(digit);Serial.print(" ");
      cursor = 86;
      for (int k = 0; k <= 27; k++) {
                Serial.print(digits[digit][k]);
        leds[cursor + k] = ledColor * digits[digit][k];
        cursor ++;
      }
            Serial.println();
    }
    Now /= 10;
  }
}

void MiseAJour()
{
  Heure += 1;
  if (Heure % 100 == 60) Heure = Heure + 40;
  Serial.print(" Mise a jour : heure = ");
  Serial.println(Heure);
}

void LectureBoutons()
{
  int EtatBPStart = digitalRead(BP_START);
  int EtatBPStop = digitalRead(BP_STOP);
  int EtatBPReset = digitalRead(BP_RESET);
  int EtatInter = digitalRead(INTER);
  if (EtatBPStart) StartChrono ();
  if (EtatBPStop) StopChrono ();
  if (EtatBPReset) ResetChrono ();
  HeureMax = 4500;
  if (EtatInter) HeureMax = 1500;
}

void loop()  // Main loop
{
  LectureBoutons();
  if (EtatChrono)
  {
    unsigned long dernierTempsChrono;
    if (millis() - dernierTempsChrono >= 1000)
    {
      MiseAJour();
      TimeToArray();
      dernierTempsChrono += 1000;
    }
  }
  FastLED.show(); // Display leds array
  if (Heure >= HeureMax) EtatChrono = false;
}

void StartChrono () {
  EtatChrono = true;
}

void StopChrono () {
  EtatChrono = false;
}

void ResetChrono () {
  EtatChrono = false;
  Heure = 0;
}