3x daily ringing of church bells

hello

Modified code does not work. you mentioned that this method is not so suitable, what do you suggest? But it would be better to count down the overlaps. Thanks

Blink without delay is the usual choice. What does that code do? Nothing?

Can you put a serial print in the bell ringing function to see whether it is ever called? I have my doubts because of the delay(1000) meaning that the sunset time is missed.

You might also call the new function from setup to check that it actually operates the bells.

I removed my part, the code works

if (sRise == RTC.get())
  {
    time_now = millis();
    while (millis() < time_now + period)
    {
      digitalWrite(zvon11, LOW); //let's magic begin
      digitalWrite(zvon12, LOW); //let's magic begin
    }
  }
  else
  {
    digitalWrite(zvon11, HIGH); //let's magic begin
    digitalWrite(zvon12, HIGH); //let's magic begin
  }

I think that you may need to use difftime to see whether the clock time is within a few seconds of sunset to ensure that you don't miss it. I would think that a margin of two or three seconds should do it.

I removed the morning bell at sunrise where it is too early in the summer and would activate it at 7am. The code works ok. How to add to the if statement to activate the ringtone even at 7.00 am and 12.00 pm?
Thanks

#include <Time.h>
#include <TimeLib.h>
#include <DS3232RTC.h>
#include <sunMoon.h>
#include <LiquidCrystal_I2C.h>

#define DS3231_I2C_ADDRESS 0x68 //RTC Address

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

#define OUR_latitude    46.056946           // Ljubljana
#define OUR_longtitude  14.505752
#define OUR_timezone    60                     // localtime with UTC difference in minutes

sunMoon  sm;

//definiraj pine za zvonove
int zvon11 = 4; //priklopi na arduino pin xx
int zvon12 = 5; //priklopi na arduino pin xy




void printDate(time_t date)
{
  char buff[20];
  sprintf(buff, "%2d-%02d-%4d %02d:%02d:%02d",
          day(date), month(date), year(date), hour(date), minute(date), second(date));
  Serial.print(buff);
}

void Time(time_t date)
{
  char buff[20];
  sprintf(buff, "%02d:%02d:%02d",
          hour(date), minute(date), second(date));
  Serial.print(buff);
  (buff);
}

//additional function
void printLcdDate(time_t date)
{
  char buff[20];
  sprintf(buff, "%02d:%02d:%02d",
          hour(date), minute(date), second(date));
  lcd.print(buff);
}
//additional function
void printLcdDate1(time_t date)
{
  char buff[20];
  sprintf(buff, "%2d-%02d-%4d",
          day(date), month(date), year(date));
  lcd.print(buff);
}

void setup()
{
  lcd.begin(20, 4);
  tmElements_t  tm;                             // specific time
  tm.Second = 0;
  tm.Minute = 12;
  tm.Hour   = 12;
  tm.Day    = 3;
  tm.Month  = 8;
  tm.Year   = 2016 - 1970;
  time_t s_date = makeTime(tm);
  Serial.begin(9600);
  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");
  sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
  Serial.print("Today is ");
  printDate(RTC.get()); Serial.println("");
  uint32_t jDay = sm.julianDay();               // Optional call
  byte mDay = sm.moonDay();
  time_t sRise = sm.sunRise();
  time_t sSet  = sm.sunSet();
  Serial.print("Today is "); Serial.print(jDay); Serial.println(" Julian day");
  Serial.print("Moon age is "); Serial.print(mDay); Serial.println("day(s)");
  Serial.print("Today sunrise and sunset: ");
  printDate(sRise); Serial.print("; ");
  printDate(sSet);  Serial.println("\t");
  Time(sRise); Serial.print("; ");
  Time(sSet);  Serial.println("");
  lcd.setCursor(0, 0);
  printLcdDate1(RTC.get());
  lcd.setCursor(12, 0);
  printLcdDate(RTC.get());
  lcd.setCursor(0, 3);
  printLcdDate(sRise);
  lcd.setCursor(12, 3);
  printLcdDate(sSet);
  Serial.print("Specific date was ");
  printDate(s_date); Serial.println("");
  jDay = sm.julianDay(s_date);
  mDay = sm.moonDay(s_date);
  sRise = sm.sunRise(s_date);
  sSet  = sm.sunSet(s_date);
  Serial.print("Specific date sunrise and sunset was: ");
  Serial.print("Julian day of specific date was "); Serial.println(jDay);
  Serial.print("Moon age was "); Serial.print(mDay); Serial.println("day(s)");
  printDate(sRise); Serial.print("; ");
  printDate(sSet);  Serial.println("");
  
  
  //definiraj outpute za relaye
  pinMode(zvon11, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon11, HIGH); // sets the digital pin LOW
  pinMode(zvon12, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon12, HIGH); // sets the digital pin LOW
}

void loop()
{
  time_t sRise = sm.sunRise();
  time_t sSet  = sm.sunSet();
  time_t sunRise(time_t date = 0);
  time_t sunSet(time_t date = 0);
  printDate(RTC.get()); Serial.print("\t");
  Time(sRise); Serial.print("\t ");
  Time(sSet);  Serial.println("");


  
  lcd.setCursor(0, 0);
  printLcdDate1(RTC.get());
  lcd.setCursor(12, 0);
  printLcdDate(RTC.get());
  lcd.setCursor(0, 3);
  printLcdDate(sRise);
  lcd.setCursor(12, 3);
  printLcdDate(sSet);
  
 //zvonenje 
  
  if(sSet == RTC.get()   )
    {
    RingSunsetBells();  
    }
  delay(1000);
}

void RingSunsetBells()
{
for(int lp=0;lp<20;lp++)
  {
  digitalWrite(zvon11, LOW);
  delay(200);
  digitalWrite(zvon11, HIGH);
  delay(800);
  digitalWrite(zvon12, LOW);
  delay(200);
  digitalWrite(zvon12, HIGH);
  delay(800);
  }
}






Here's a way to do it:

#include <Time.h>
#include <TimeLib.h>
#include <DS3232RTC.h>
#include <sunMoon.h>
#include <LiquidCrystal_I2C.h>

#define DS3231_I2C_ADDRESS 0x68 //RTC Address

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

#define OUR_latitude    46.056946           // Ljubljana
#define OUR_longtitude  14.505752
#define OUR_timezone    60                     // localtime with UTC difference in minutes

sunMoon  sm;

//definiraj pine za zvonove
int zvon11 = 4; //priklopi na arduino pin xx
int zvon12 = 5; //priklopi na arduino pin xy




void printDate(time_t date)
{
  char buff[20];
  sprintf(buff, "%2d-%02d-%4d %02d:%02d:%02d",
          day(date), month(date), year(date), hour(date), minute(date), second(date));
  Serial.print(buff);
}

void Time(time_t date)
{
  char buff[20];
  sprintf(buff, "%02d:%02d:%02d",
          hour(date), minute(date), second(date));
  Serial.print(buff);
  (buff);
}

//additional function
void printLcdDate(time_t date)
{
  char buff[20];
  sprintf(buff, "%02d:%02d:%02d",
          hour(date), minute(date), second(date));
  lcd.print(buff);
}
//additional function
void printLcdDate1(time_t date)
{
  char buff[20];
  sprintf(buff, "%2d-%02d-%4d",
          day(date), month(date), year(date));
  lcd.print(buff);
}

void setup()
{
  lcd.begin(20, 4);
  tmElements_t  tm;                             // specific time
  tm.Second = 0;
  tm.Minute = 12;
  tm.Hour   = 12;
  tm.Day    = 3;
  tm.Month  = 8;
  tm.Year   = 2016 - 1970;
  time_t s_date = makeTime(tm);
  Serial.begin(115200);
  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");
  sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
  Serial.print("Today is ");
  printDate(RTC.get()); Serial.println("");
  uint32_t jDay = sm.julianDay();               // Optional call
  byte mDay = sm.moonDay();
  time_t sRise = sm.sunRise();
  time_t sSet  = sm.sunSet();
  Serial.print("Today is "); Serial.print(jDay); Serial.println(" Julian day");
  Serial.print("Moon age is "); Serial.print(mDay); Serial.println("day(s)");
  Serial.print("Today sunrise and sunset: ");
  printDate(sRise); Serial.print("; ");
  printDate(sSet);  Serial.println("\t");
  Time(sRise); Serial.print("; ");
  Time(sSet);  Serial.println("");
  lcd.setCursor(0, 0);
  printLcdDate1(RTC.get());
  lcd.setCursor(12, 0);
  printLcdDate(RTC.get());
  lcd.setCursor(0, 3);
  printLcdDate(sRise);
  lcd.setCursor(12, 3);
  printLcdDate(sSet);
  Serial.print("Specific date was ");
  printDate(s_date); Serial.println("");
  jDay = sm.julianDay(s_date);
  mDay = sm.moonDay(s_date);
  sRise = sm.sunRise(s_date);
  sSet  = sm.sunSet(s_date);
  Serial.print("Specific date sunrise and sunset was: ");
  Serial.print("Julian day of specific date was "); Serial.println(jDay);
  Serial.print("Moon age was "); Serial.print(mDay); Serial.println("day(s)");
  printDate(sRise); Serial.print("; ");
  printDate(sSet);  Serial.println("");
  //definiraj outpute za relaye
  pinMode(zvon11, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon11, HIGH); // sets the digital pin LOW
  pinMode(zvon12, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon12, HIGH); // sets the digital pin LOW
}

void loop()
{
  time_t sRise = sm.sunRise();
  time_t sSet  = sm.sunSet();
  time_t sunRise(time_t date = 0);
  time_t sunSet(time_t date = 0);
  time_t timeNow=RTC.get();
  printDate(timeNow); Serial.print("\t");
  Time(sRise); Serial.print("\t ");
  Time(sSet);  Serial.println("");
  lcd.setCursor(0, 0);
  printLcdDate1(timeNow);
  lcd.setCursor(12, 0);
  printLcdDate(timeNow);
  lcd.setCursor(0, 3);
  printLcdDate(sRise);
  lcd.setCursor(12, 3);
  printLcdDate(sSet);
  if(hour(timeNow)==12 && minute(timeNow)==0 && second(timeNow)==0)
    {
    RingNoonBells();  
    }
  if (sSet == timeNow)
    {
    RingSunsetBells();
    }
  delay(500);
}

void RingNoonBells()
{
// Do ring pattern for noon  
}

void RingSunsetBells()
{
  for (int lp = 0; lp < 20; lp++)
  {
    digitalWrite(zvon11, LOW);
    delay(200);
    digitalWrite(zvon11, HIGH);
    delay(800);
    digitalWrite(zvon12, LOW);
    delay(200);
    digitalWrite(zvon12, HIGH);
    delay(800);
  }
}

There are several changes. Serial baud rate is raised, timeNow variable ensures the clock is only read once per iteration. The delay at the end has been reduced to try and avoid missing a time.

You will need to fill in whatever the noon bells do. If it works, you can use the same pattern for the morning bells.

great thanks for your help it works as it should.
last request. I divided the ringing into 7.00 and 12.00 then the bell rings 1. this is arranged.
Now I would like to create when the sunset rings alternately bell1 and bell2 ring each 1/3 I added 2pin
bell1 ----> bell2, ----> bell1

thanks
.....

#include <Time.h>
#include <TimeLib.h>
#include <DS3232RTC.h>
#include <sunMoon.h>
#include <LiquidCrystal_I2C.h>

#define DS3231_I2C_ADDRESS 0x68 //RTC Address

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

#define OUR_latitude    46.056946           // Ljubljana
#define OUR_longtitude  14.505752
#define OUR_timezone    60                     // localtime with UTC difference in minutes

sunMoon  sm;

//definiraj pine za zvonove
int zvon11 = 4; //priklopi na arduino pin xx
int zvon12 = 5; //priklopi na arduino pin xy
int zvon21 = 6; //priklopi na arduino pin xx
int zvon22 = 7; //priklopi na arduino pin xy





void printDate(time_t date)
{
  char buff[20];
  sprintf(buff, "%2d-%02d-%4d %02d:%02d:%02d",
          day(date), month(date), year(date), hour(date), minute(date), second(date));
  Serial.print(buff);
}

void Time(time_t date)
{
  char buff[20];
  sprintf(buff, "%02d:%02d:%02d",
          hour(date), minute(date), second(date));
  Serial.print(buff);
  (buff);
}

//additional function
void printLcdDate(time_t date)
{
  char buff[20];
  sprintf(buff, "%02d:%02d:%02d",
          hour(date), minute(date), second(date));
  lcd.print(buff);
}
//additional function
void printLcdDate1(time_t date)
{
  char buff[20];
  sprintf(buff, "%2d-%02d-%4d",
          day(date), month(date), year(date));
  lcd.print(buff);
}

void setup()
{
  lcd.begin(20, 4);
  tmElements_t  tm;                             // specific time
  tm.Second = 0;
  tm.Minute = 12;
  tm.Hour   = 12;
  tm.Day    = 3;
  tm.Month  = 8;
  tm.Year   = 2016 - 1970;
  time_t s_date = makeTime(tm);
  Serial.begin(115200);
  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");
  sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
  Serial.print("Today is ");
  printDate(RTC.get()); Serial.println("");
  uint32_t jDay = sm.julianDay();               // Optional call
  byte mDay = sm.moonDay();
  time_t sRise = sm.sunRise();
  time_t sSet  = sm.sunSet();
  Serial.print("Today is "); Serial.print(jDay); Serial.println(" Julian day");
  Serial.print("Moon age is "); Serial.print(mDay); Serial.println("day(s)");
  Serial.print("Today sunrise and sunset: ");
  printDate(sRise); Serial.print("; ");
  printDate(sSet);  Serial.println("\t");
  Time(sRise); Serial.print("; ");
  Time(sSet);  Serial.println("");
  lcd.setCursor(0, 0);
  printLcdDate1(RTC.get());
  lcd.setCursor(12, 0);
  printLcdDate(RTC.get());
  lcd.setCursor(0, 3);
  printLcdDate(sRise);
  lcd.setCursor(12, 3);
  printLcdDate(sSet);
  Serial.print("Specific date was ");
  printDate(s_date); Serial.println("");
  jDay = sm.julianDay(s_date);
  mDay = sm.moonDay(s_date);
  sRise = sm.sunRise(s_date);
  sSet  = sm.sunSet(s_date);
  Serial.print("Specific date sunrise and sunset was: ");
  Serial.print("Julian day of specific date was "); Serial.println(jDay);
  Serial.print("Moon age was "); Serial.print(mDay); Serial.println("day(s)");
  printDate(sRise); Serial.print("; ");
  printDate(sSet);  Serial.println("");
  //definiraj outpute za relaye
  pinMode(zvon11, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon11, HIGH); // sets the digital pin LOW
  pinMode(zvon12, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon12, HIGH); // sets the digital pin LOW
  pinMode(zvon21, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon21, HIGH); // sets the digital pin LOW
  pinMode(zvon22, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon22, HIGH); // sets the digital pin LOW


  
}


void loop()
{
  time_t sRise = sm.sunRise();
  time_t sSet  = sm.sunSet();
  time_t sunRise(time_t date = 0);
  time_t sunSet(time_t date = 0);
  time_t timeNow=RTC.get();
  printDate(timeNow); Serial.print("\t");
  Time(sRise); Serial.print("\t ");
  Time(sSet);  Serial.println("");
  lcd.setCursor(0, 0);
  printLcdDate1(timeNow);
  lcd.setCursor(12, 0);
  printLcdDate(timeNow);
  lcd.setCursor(0, 3);
  printLcdDate(sRise);
  lcd.setCursor(12, 3);
  printLcdDate(sSet);

 // ring 1 Bell  -------7.00 and 12.00
 
  if(hour(timeNow)==7 && minute(timeNow)==0 && second(timeNow)==0)
  if(hour(timeNow)==12 && minute(timeNow)==0 && second(timeNow)==0)
    {
    Ring_1_Bells();  
    }
 
 //ring 2 bell---------- 7.00, 12.00 and sunset
  
  if (sSet == timeNow)
    {
    RingSunsetBells();
    }
  delay(500);
}

void RingSunsetBells()
{
  for (int lp = 0; lp < 20; lp++)
  {
    digitalWrite(zvon11, LOW);
    delay(200);
    digitalWrite(zvon11, HIGH);
    delay(800);
    digitalWrite(zvon12, LOW);
    delay(200);
    digitalWrite(zvon12, HIGH);
    delay(800);
  }
}

void Ring_1_Bells()
{
  for (int lp = 0; lp < 20; lp++)
  {
    digitalWrite(zvon11, LOW);
    delay(200);
    digitalWrite(zvon11, HIGH);
    delay(800);
    digitalWrite(zvon12, LOW);
    delay(200);
    digitalWrite(zvon12, HIGH);
    delay(800);
  }
}

I'm not sure I understand what you're asking for sunset.

The code for 7AM and non is flawed though. As it stands, it's checking that the time is 7AM and also noon. It obviously can't be both. I suggest that you have a separate call to ring_1_bell for each if, although there are other ways to do it.

#include <Time.h>
#include <TimeLib.h>
#include <DS3232RTC.h>
#include <sunMoon.h>
#include <LiquidCrystal_I2C.h>

#define DS3231_I2C_ADDRESS 0x68 //RTC Address

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

#define OUR_latitude    46.056946           // Ljubljana
#define OUR_longtitude  14.505752
#define OUR_timezone    60                     // localtime with UTC difference in minutes

sunMoon  sm;

//definiraj pine za zvonove
int zvon11 = 4; //priklopi na arduino pin xx
int zvon12 = 5; //priklopi na arduino pin xy
int zvon21 = 6; //priklopi na arduino pin xx
int zvon22 = 7; //priklopi na arduino pin xy





void printDate(time_t date)
{
  char buff[20];
  sprintf(buff, "%2d-%02d-%4d %02d:%02d:%02d",
          day(date), month(date), year(date), hour(date), minute(date), second(date));
  Serial.print(buff);
}

void Time(time_t date)
{
  char buff[20];
  sprintf(buff, "%02d:%02d:%02d",
          hour(date), minute(date), second(date));
  Serial.print(buff);
  (buff);
}

//additional function
void printLcdDate(time_t date)
{
  char buff[20];
  sprintf(buff, "%02d:%02d:%02d",
          hour(date), minute(date), second(date));
  lcd.print(buff);
}
//additional function
void printLcdDate1(time_t date)
{
  char buff[20];
  sprintf(buff, "%2d-%02d-%4d",
          day(date), month(date), year(date));
  lcd.print(buff);
}

void setup()
{
  lcd.begin(20, 4);
  tmElements_t  tm;                             // specific time
  tm.Second = 0;
  tm.Minute = 12;
  tm.Hour   = 12;
  tm.Day    = 3;
  tm.Month  = 8;
  tm.Year   = 2016 - 1970;
  time_t s_date = makeTime(tm);
  Serial.begin(115200);
  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");
  sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
  Serial.print("Today is ");
  printDate(RTC.get()); Serial.println("");
  uint32_t jDay = sm.julianDay();               // Optional call
  byte mDay = sm.moonDay();
  time_t sRise = sm.sunRise();
  time_t sSet  = sm.sunSet();
  Serial.print("Today is "); Serial.print(jDay); Serial.println(" Julian day");
  Serial.print("Moon age is "); Serial.print(mDay); Serial.println("day(s)");
  Serial.print("Today sunrise and sunset: ");
  printDate(sRise); Serial.print("; ");
  printDate(sSet);  Serial.println("\t");
  Time(sRise); Serial.print("; ");
  Time(sSet);  Serial.println("");
  lcd.setCursor(0, 0);
  printLcdDate1(RTC.get());
  lcd.setCursor(12, 0);
  printLcdDate(RTC.get());
  lcd.setCursor(0, 3);
  printLcdDate(sRise);
  lcd.setCursor(12, 3);
  printLcdDate(sSet);
  Serial.print("Specific date was ");
  printDate(s_date); Serial.println("");
  jDay = sm.julianDay(s_date);
  mDay = sm.moonDay(s_date);
  sRise = sm.sunRise(s_date);
  sSet  = sm.sunSet(s_date);
  Serial.print("Specific date sunrise and sunset was: ");
  Serial.print("Julian day of specific date was "); Serial.println(jDay);
  Serial.print("Moon age was "); Serial.print(mDay); Serial.println("day(s)");
  printDate(sRise); Serial.print("; ");
  printDate(sSet);  Serial.println("");
  //definiraj outpute za relaye
  pinMode(zvon11, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon11, HIGH); // sets the digital pin LOW
  pinMode(zvon12, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon12, HIGH); // sets the digital pin LOW
  pinMode(zvon21, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon21, HIGH); // sets the digital pin LOW
  pinMode(zvon22, OUTPUT);    // sets the digital pin to output
  digitalWrite(zvon22, HIGH); // sets the digital pin LOW


  
}


void loop()
{
  time_t sRise = sm.sunRise();
  time_t sSet  = sm.sunSet();
  time_t sunRise(time_t date = 0);
  time_t sunSet(time_t date = 0);
  time_t timeNow=RTC.get();
  printDate(timeNow); Serial.print("\t");
  Time(sRise); Serial.print("\t ");
  Time(sSet);  Serial.println("");
  lcd.setCursor(0, 0);
  printLcdDate1(timeNow);
  lcd.setCursor(12, 0);
  printLcdDate(timeNow);
  lcd.setCursor(0, 3);
  printLcdDate(sRise);
  lcd.setCursor(12, 3);
  printLcdDate(sSet);

 // ringing time 7.00------1 Bell
 
  if(hour(timeNow)==7 && minute(timeNow)==0 && second(timeNow)==0)
    {
    Ring_1_Bells();  
    }
    
 // ringing time 12.00-----1 bell
  
  if(hour(timeNow)==12 && minute(timeNow)==0 && second(timeNow)==0)
    {
    Ring_1_Bells();  
    }

 
 //ringing time sunset------1,2 bells
  
  if (sSet == timeNow)
    {
    RingSunsetBells();
    }
  delay(500);
}

void Ring_1_Bells()
{
  for (int lp = 0; lp < 120; lp++)
  {
    digitalWrite(zvon11, LOW);
    delay(200);
    digitalWrite(zvon11, HIGH);
    delay(800);
    digitalWrite(zvon12, LOW);
    delay(200);
    digitalWrite(zvon12, HIGH);
    delay(800);
  }
}

void RingSunsetBells()
{
  for (int lp = 0; lp < 40; lp++)
  {
    digitalWrite(zvon11, LOW);
    delay(200);
    digitalWrite(zvon11, HIGH);
    delay(800);
    digitalWrite(zvon12, LOW);
    delay(200);
    digitalWrite(zvon12, HIGH);
    delay(800);
  }
}

I fixed it.
ringing at 7.00 and 12.00 I set to 120 beats
I want the sunset ringing to work the way it does
bell 1 -40 beats -> bell 2-40 beats -> bell 1 - 40 beats

Thanks

Is this what you mean?

void Ring_1_Bells()
{
for (int lp = 0; lp < 40; lp++)
  {
  digitalWrite(zvon11, LOW);
  delay(200);
  digitalWrite(zvon11, HIGH);
  delay(800);
  }
for (int lp = 0; lp < 40; lp++)
  {
  digitalWrite(zvon12, LOW);
  delay(200);
  digitalWrite(zvon12, HIGH);
  delay(800);
  }
for (int lp = 0; lp < 40; lp++)
  {
  digitalWrite(zvon11, LOW);
  delay(200);
  digitalWrite(zvon11, HIGH);
  delay(800);
  }
}

works thanks.

some fine-tuning will be required after testing to see if there will be any errors

void RingSunsetBells()
{
for (int lp = 0; lp < 5; lp++)
  {
    digitalWrite(zvon11, LOW);
    delay(200);
    digitalWrite(zvon11, HIGH);
    delay(800);
    digitalWrite(zvon12, LOW);
    delay(200);
    digitalWrite(zvon12, HIGH);
    delay(800);
  }
for (int lp = 0; lp < 5; lp++)
  {
    digitalWrite(zvon21, LOW);
    delay(200);
    digitalWrite(zvon21, HIGH);
    delay(800);
    digitalWrite(zvon22, LOW);
    delay(200);
    digitalWrite(zvon22, HIGH);
    delay(800);
  }
for (int lp = 0; lp < 5; lp++)
  {
    digitalWrite(zvon11, LOW);
    delay(200);
    digitalWrite(zvon11, HIGH);
    delay(800);
    digitalWrite(zvon12, LOW);
    delay(200);
    digitalWrite(zvon12, HIGH);
    delay(800);
  }
}

but I wonder why the clock on the lcd stops when the interval is activated. it seems to count in the background.

The LCD time is read from the RTC which keeps track of the time whether you read from it or not. However, When you're ringing the sunset bells, there are thirty seconds of delays in the function you just posted, so the LCD is not refreshed until it's done.

This is a classic example of what I mentioned earlier - eventually, it becomes apparent that use of delay was a bad idea, and here we are.

I am not sure why it matters really, but if it actually does, you can either put some code in RingSunsetBells to refresh the LCD between delays or the whole thing has to be refactored to work without delays.

ok now i understand the operation but my knowledge is not so extensive that to solve this problem the ring cycles will take 2min. It doesn't bother me if he doesn't show the clock at that time, it's more important to me that the clock won't be late

Your DS3231 will keep track of the time. You should see the time leap forward when the bells are done.