TimeAlarm library

Dear everyone,
I am currently working on a project : a device that is rings a bell (by activating a solenoid) and fade in and out a led every hours.

As i am not a super programmer I have used the "TimeAlarm action" that quite easy to use with an RTC clock. As I don't want to hear the bell during the night, I have a loop for the night and loop for the day. But it seams that there is a limit to alarm time library.... every thing works fine in my programm exept that nothing happens at the programed moments (every hours). It works only when there is just 5 alarm times programmed. Is the "TimeAlarm function limited?
Here is my code. Advise welcome! ;D

#include "Wire.h"
#include <Time.h>
#include <TimeAlarms.h>
#include <DS1307RTC.h>  

const byte ledPin =  9;    // LED to pin 9
int magnetPin =  7;    // SOLENOID to digit 7

void setup()
{
  byte second, minute, hour;
  Wire.begin();
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(magnetPin, OUTPUT);

  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if(timeStatus()!= timeSet) 
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");  


 Alarm.alarmRepeat(8,0,0,alarm1);// Alarm with bell
 Alarm.alarmRepeat(9,0,0,alarm1);
 Alarm.alarmRepeat(10,0,0,alarm1);
 Alarm.alarmRepeat(11,0,0,alarm1);
 Alarm.alarmRepeat(12,0,0,alarm1);
 Alarm.alarmRepeat(13,0,0,alarm1);
 Alarm.alarmRepeat(14,0,0,alarm1);
 Alarm.alarmRepeat(15,0,0,alarm1);
 Alarm.alarmRepeat(16,0,0,alarm1);
 Alarm.alarmRepeat(17,0,0,alarm1);
 Alarm.alarmRepeat(18,0,0,alarm1);
 Alarm.alarmRepeat(19,0,0,alarm1);
 Alarm.alarmRepeat(20,0,0,alarm1);
 Alarm.alarmRepeat(21,25,0,alarm1);
 Alarm.alarmRepeat(22,0,0,alarm2);// Alarm without bell  
 Alarm.alarmRepeat(23,0,0,alarm2);  
 Alarm.alarmRepeat(0,0,0,alarm2);  
 Alarm.alarmRepeat(1,0,0,alarm2);
 Alarm.alarmRepeat(2,0,0,alarm2);  
 Alarm.alarmRepeat(3,0,0,alarm2);
 Alarm.alarmRepeat(4,0,0,alarm2);
 Alarm.alarmRepeat(5,0,0,alarm2);  
 Alarm.alarmRepeat(6,0,0,alarm2);
 Alarm.alarmRepeat(7,0,0,alarm2);

}

void  loop(){  
  digitalClockDisplay();
  Alarm.delay(1000); // wait one second between clock display
}
// fading in function
void fadeIn(long duration, int pinum) {
  const long delayTime = duration / 255;
  for (byte i = 0; i < 255; ++i) {
    analogWrite(pinum, i);
    delay(delayTime);
  }
  digitalWrite(pinum, HIGH);
}
// fading out function
void fadeOut(long duration, int pinum) {
  const long delayTime = duration / 255;
  for (byte i = 255; i > 0; --i) {
    analogWrite (pinum, i);
    delay(delayTime);
  }
  digitalWrite(pinum, LOW);   

}
// solenoid control
void magnet(){
  digitalWrite(magnetPin, HIGH);
  delay(20);
  digitalWrite(magnetPin, LOW);
 
  
}  
// alarm 1 with sound and light
void alarm1(){
  Serial.println("ALARM 1-with sound");
  fadeIn(30, ledPin);
  magnet();
  fadeOut(15000, ledPin);

}   
// alarm 2 light only
void alarm2(){
  Serial.println("ALARM 2-without sound");
  fadeIn(30, ledPin);
  fadeOut(15000, ledPin);

}   
void digitalClockDisplay()
{
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.println(); 
}

void printDigits(int digits)
{
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);

}

See TimeAlarm isn't working sometimes

How would YOU activate, or not, the solenoid based on the time of day? Would YOU be using an alarm clock? Of course not. You'd be using either a watch or looking outside to see if it was dark.

Dump the TimeAlarm class (not that there is anything wrong with it, mind you) and learn to do it yourself first.

Thanks for the orientations. Well dear PaulS, I know what you mean but it was not exactly my question It's not ME that will turn in an out the light and solenoid neither the sun light or any other extra elements that could be detected by sensors. My project is in relation with time (the human abstract concept that divide the course of sun in 24 units) an so it has to be linked to a clock (the device that is basically counting this segmentation). So I need resources like Time Alarm library to do so and as I am facing an issue I think it is a good idea to ask help and advice on this forum. I learn a lot by myself but so much more from others ( like many of us I guess)....

So I need resources like Time Alarm library to do so

No, you don't. You have an RTC. You, therefore. KNOW what time it is. It is trivial to write an if statement.

bool beenThereDoneThat = false;

void loop()
{
   // Get the time from the clock has h, m, and s

   if(h == startHour && m = startMin && s == 0)
   {
      if(!beenThereDoneThat)
      {
         // It's time to do whatever
         beenThereDoneThat = true;
      }
   }
   else
      beenThereDoneThat = false;
}

The beenThereDoneThat flag is so that you don't start whatever over and over for a full second.

poupakiko:
It works only when there is just 5 alarm times programmed. Is the "TimeAlarm function limited?

Yes.
Go edit the library header file to increase the maximum number of alarm events.
Look for this line and change it to be however many you want up to 255.

#define dtNBR_ALARMS 6

--- bill

I don´t understand why you are using TimeAlarms for that.
wouldn´t it work if you do something like:

if (hour() >= 8 && hour() <= 21 && hour() != oldhour)
{
oldhour = hour();
alarm1();
}

else
{
alarm2();
}