I need help with my code for a school bell system

I installed a bell system at my college that rings a bell on spesific time during the day. I have a Time switch that switches on at 7:45 every day for 1 minute to tell my arduino when to start counting. The arduino output is connected to a relay module that switches an old-school fire bell for just 1 second. I have my code below but as you can see my programming skills are very weak.

It has been working fine so far but People are telling me it randomly rings during night and that when the electricity goes off and on it will not work unless I reset it manually.

Can anyone check my code and tell me what I can do to improve it?

const int timerPin = 4;
const int bellPin = 7;
const int ledPin = 13;
boolean runOnce = true;

//  5 mins = 300000
// 10 mins = 600000
// 15 mins = 900000
// 20 mins = 1200000
// 30 mins = 1800000
// 55 mins = 3300000
// 60 mins = 3600000

void setup() {
  pinMode(bellPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(timerPin, INPUT);
  digitalWrite(bellPin,HIGH);
  runOnce = true;
  digitalWrite(ledPin, LOW);
}

void loop() {
  if ((runOnce==true)&&(digitalRead(timerPin) == HIGH)) {
      runOnce=false;
      daily();
      delay(1000);
  }
}

void daily(){
      digitalWrite(ledPin, HIGH);
      delay(1000);
      ring();//7:45
      delay(600000);
      ring();//7:55
      delay(300000);
      ring();//8:00
      delay(3300000);
      ring();//8:55
      delay(3300000);
      ring();//9:50
      delay(1200000);
      ring();//10:10
      delay(3300000);
      ring();//11:05
      delay(3300000);
      ring();//12:00
      delay(3300000);
      ring();//12:55
      delay(300000);
      ring();//13:00
      delay(3600000);
      ring();//14:00
      delay(3600000);
      ring();//15:00
      delay(3600000);
      ring();//16:00
      delay(3600000);
      ring();//17:00


      delay(1000);
      digitalWrite(ledPin, LOW);
      runOnce=true;
  }


void ring(){
  delay(1000);
  digitalWrite(bellPin,LOW);
  delay(1000);// Set how long it rings. is at 1secnow
  digitalWrite(bellPin,HIGH);
  delay(1000);
}

You really need an RTC (real time clock) module like: https://www.amazon.com/Wrisky-Precision-Memory-Arduino-AT24C32/dp/B01KT6S3XK/ref=sr_1_11?ie=UTF8&qid=1508226330&sr=8-11&keywords=rtc+module+ds3231 And library that will let you schedule a whole day's events easily and maintain correct time even with power off. The Arduino's oscillator can be off by several seconds per hour, especially with varying temperature. Google "Arduino RTC library". No offense intended, but your code stinks. :)

Yup. Use a real-time clock. They have a battery backup, and the arduino resonator is not accurate - it's a little temperature sensitive.

edgemoron: No offense intended, but your code stinks. :)

I strongly disagree with this undeserved negative statement.

The code is too simplistic in a sense it does not take into account the fact that the arduino Built in “Time management” is heavily inaccurate but the code is indented correctly, constants are defined for pins (could do as well for delays) variables have meaningful names, and structure is based on basic principles of sequencing actions with known delays. It’s simple to read.

So in a nutshell, No offense intended, but your Comment stinks :)... (and everyone is free to have an opinion and express it)

Using the RTC was a good comment though :-)

@J-M-L: Did you BCC this to @PaulS? I've never seen a comment from you when HE makes similar comments 10 + times a day.

I've never seen a comment from you when HE makes similar comments 10 + times a day.

That's because I explain WHY the code smells to high heaven.

Well no I didn't

1/ I'm a grown up, I have my own opinions and I express them

2/ it's not because Paul is sometimes rough that you need to try to copy his style. Or if you do then do it when it's appropriate. I actually often agree with him when he sees "poor" code.

--> we probably don't have the same definition of code that "stinks"...

but that's OK, it's a free world