creation d'une sonnette scolaire

Bon, comme j'ai déjà posté un truc équivalent dans le forum US - voici un bout de code simpliste qui allume la LED intégrée quand l'heure de la journée est un des intervalles donnés dans le tableau slots[][].

il n'y a pas de gestion des jours (pas de prise en compte des week end) donc ça vous laisse un peu de boulot à effectuer et bien sûr il faudra adapter les time slots ainsi que le pilotage du relai s'il doit osciller

// *************************************************************
// Timing
// *************************************************************


const uint32_t hour_s = 3600ul, min_s = 60ul; // nb of seconds in 1h or 1min

// define when relay is ON through intervals, representing the number of seconds since midnight
const uint32_t slots[][2] = {
  {14 * hour_s + 24 * min_s + 0 , 14 * hour_s + 24 * min_s + 30},   // [14:24:00 , 14:24:30]
  {23 * hour_s + 27 * min_s + 30, 23 * hour_s +  29 * min_s},       // [23:27:30 , 23:29:00]
  {23 * hour_s + 30 * min_s + 30, 23 * hour_s +  31 * min_s}        // [23:30:30 , 23:31:00]
};


// *************************************************************
// RTC 
// *************************************************************
#include "RTClib.h" // https://github.com/adafruit/RTClib (import adafruit RTCLib library)
RTC_DS3231 rtc;


// *************************************************************
// Relay management
// *************************************************************
void handleRelay()
{
  const byte nbSlots = sizeof(slots) / sizeof(slots[0]);
  static int currentActiveSlot = -1;
  int slot = -1;

  DateTime now = rtc.now();
  uint32_t t = now.hour() * hour_s + now.minute() * min_s + now.second();

  for (byte i = 0; i < nbSlots; i++) {
    if ((t >= slots[i][0]) && (t <= slots[i][1])) {
      slot = i;
      break;
    }
  }

  if (slot != currentActiveSlot) {
    // something has changed
    if (slot == -1) {
      // we are not in a slot, so turn relay OFF
      digitalWrite(LED_BUILTIN, LOW);
      Serial.print(F("End of slot #"));
      Serial.println(currentActiveSlot);
    } else {
      // we are entering a time slot, so turn relay ON
      digitalWrite(LED_BUILTIN, HIGH);
      Serial.print(F("Entering in slot #"));
      Serial.println(slot);
    }
    currentActiveSlot = slot;
  }
}

// *************************************************************

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW); // turn relay OFF (assuming LOW is OFF)

  // start RTC
  if (! rtc.begin()) {
    Serial.print("Couldn't find RTC!");
    while (1); // can't go further
  }
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // only if your clock is not set up
}

// *************************************************************
void loop() {
  handleRelay();
}