Automatic School Bell Arduino Project| Time Table Bell Alarm

Automatic school Bell project is very useful project which can be use in school as well as in college. Hey guys, welcome back to the techatronic. this time we made a good project. As all we know how the school and college bell work. there is a person who rings the bell when required. when a particular subject period over and the next subject period started.What if there were a microcontroller which controls the automatic school bell which rings itself according to a timetable. This project is the implementation of same functionality.

automatic school bell Arduino Project

The automatic school bell has a feature where you need to enter the timetable there only. in this system you can enter the start and end times. also there is an option for break. also, we can enter the subject name and time duration. for example we can fed 1st period math 2nd period english and so on. we have option for 8 period and two break.

We are using EEPROM in this project to save the data. so, once you fed the data into the system then the data will be save until you erase the EEPROM memory in this Automatic school Bell project .

Electrically Erasable Programmable Read-only Memory is the full name of the EEPROM. where all the data will be saved until you force to erase the data. so, our timetable will not be erased from the system.

This project can be installed in each class. so all the students and staff can see the information in display. There is a bell also attached. date and time, subject and duration all the information will be displayed on LCD. this is the best way to smart your school or colleges. there is many other project which can be deployed in the school and colleges. such as the attendance system project. and smart home automation system.

Here, we are going to make this Automatic school Bell project using Arduino step by step with all the information code & circuit and everything. if you want to make and learn this awesome project you need to read full article. also, we have uploaded video on youtube for which we given a link below. so, let get started the automatic school bell alarm. first we need to know the required components.

Arduino-based school bell project Required Components.

  • Arduino nano
  • RTC 1307 module
  • push button
  • relay
  • bc547 transistor
  • IN4007 diode
  • 1k Resistor
  • 16×2 LCD display
  • Normal electrical bell

Arduino Nano:- Arduino nano is smallest version of Arduino . small but powerful. there is 14 GPIO and 8 analog pins. also support all king of communication protocol. Here arduino is working like a brain and controlling all the components and modules. from extracting data from the RTC module to display the information on LCD display.

arduino nano

RTC 1307 module:- RTC (real time clock) is a module which save the time in an EEPROM. and where a small coin cell battery help it to do this. there is 1307 IC which count the numbers as per seconds and update the time inside the RTC module. by the combination of both IC’s the RTC module can save the real time into the memory. in this Automatic school Bell project RTC save the time itself.

rtc 1307

push Button:- push button is a type of switch which help to make the circuit close and open. when we press a push button the circuit will close and when we release the push button the circuit again open. so, in this project the push button give input to the arduino buy the user. when user press the input button. arduino change the commands.

push button

Relay:- Relay is a automatic type of “off & on” switch. when a triggered voltage given to the relay the relay will automatically close the circuit. and when no voltage across the relay input the relay will open the circuit. the relay only doing open and close circuit.

Resistor , diode and transistor detail can be found here – Basic electronics

Automatic School Bell Project Circuit Diagram

Automatic school Bell arduino project circuit

Here, the circuit diagram is given. also, we are sharing the connection detail here.

Connect Arduino pin 13 & 12 to LCD pin Rs and Enable respectively

Connect Arduino 6,5,4,3 pin to the LCD pin D4, D3,D2,D1 respectively.

Connect both ground pin from LCD to Arduino Ground pin.

Connect both Vcc pin to Arduino 5v pin.

Connect potentiometer T1 means left side pin to ground and right side pin to 5V

Connect the potentiometer middle pin to thee LCD V0 pin.

Connect push button 1,2,3,4 one pin common to the ground

Connect push button Remaining 1 pin to the A0,A1,A2,A3 of Arduino nano.

Connect RTC 1307 SDA, SCL pin to Arduino nano A4,A5 pin respectively

Connect RTC Ground and Vcc to the Arduino ground and VCC.

Connect Relay Vcc and Ground pin to the Arduino ground and 5V pin.

Connect Arduino pin 7 to the Relay Input pin.

Automatic school Bell project Video Sample

Automatic school Bell project connection table

Arduino NanoRTC Module16X2 LCD PotentiometerPush button
13RS
12E
6D4
5D3
4D2
3D1
GndGndGND, KT1
5vVccVcc, VddT2 (T3 -V0 LCD)
A0P1
A1P2
A2P3
A3P4
7
A4SDA
A5SCL

Automatic school Bell Arduino Code

#include <Wire.h>

#include<EEPROM.h>

#include "RTClib.h"


#include <LiquidCrystal.h>

LiquidCrystal lcd(13, 12, 6, 5, 4, 3);// Pins used for RS,E,D4,D5,D6,D7

RTC_DS1307 rtc;

char* mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"};

char daysOfTheWeek[7][12] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int subject[7];

int buzzer=7;//Pin declare for buzzer control at pin number 24 of arduino mega

int b1 = A0;     // the number of the pushbutton pin

int b2 = A1;      // the number of the LED pin                              

int b3 = A2;      // the number of the LED pin    

int b4 = A3;      // the number of the LED pin                

int bS1 = 0;

int bS2 = 0;   

int bS3 = 0; 

int bS4 = 0; 

int newTime,newHour,prevTime=0,prevHour=0,a=0,hoursE=0,hoursH=0, countTime=60;

int i=0,j=0,k=0,var,nextSUB=0,value,pos=0,periodtime=0,starttime=0,endtime=0,totaltime=0,break1=0,break2=0; 

int monA=6,tueA=12,wedA=17,thuA=22,friA=27,satA=32,brk1,brk2,noPeriod=0;

int HOUR,MINUT,SECOND,timeH,timeM,setT=0,breakR=0;



byte Aalpha[8] ={ 0b00000,

                   0b01110,

                   0b10001,

                   0b11111,

                   0b10001,

                   0b10001,

                   0b00000,

                   0b00000

                   };

 byte Balpha[8]={ 0b00000,

                    0b11100,

                    0b10010,

                    0b11100,

                    0b10010,

                    0b11100,

                    0b00000,

                    0b00000};

  byte Calpha[8]={   0b00000,

                     0b01110,

                     0b10000,

                     0b10000,

                     0b10000,

                     0b01110,

                     0b00000,

                     0b00000};                   

 byte Dalpha[8] ={ 0b00000,

                   0b11100,

                   0b10010,

                   0b10010,

                   0b10010,

                   0b11100,

                   0b00000,

                   0b00000};

  byte Ealpha[8] ={0b00000,

                   0b11110,

                   0b10000,

                   0b11100,

                   0b10000,

                   0b11110,

                   0b00000,

                   0b00000}; 

  byte Falpha[8] ={0b00000,

                   0b11110,

                   0b10000,

                   0b11100,

                   0b10000,

                   0b10000,

                   0b00000,

                   0b00000};

    byte Galpha[8]={0b00000,

                    0b01110,

                    0b10000,

                    0b10110,

                    0b10010,

                    0b01110,

                    0b00000,

                    0b00000};

   byte Halpha[8] ={ 0b00000,

                   0b10001,

                   0b10001,

                   0b11111,

                   0b10001,

                   0b10001,

                   0b00000,

                   0b00000};  

   byte Ialpha[8]={0b00000,

                     0b01110,

                     0b00100,

                     0b00100,

                     0b00100,

                     0b01110,

                     0b00000,

                     0b00000}; 

    byte Lalpha[8]={ 0b00000,

                     0b10000,

                     0b10000,

                     0b10000,

                     0b10000,

                     0b11110,

                     0b00000,

                     0b00000}; 

   byte Malpha[8] ={ 0b00000,

                    0b10001,

                   0b11011,

                   0b10101,

                   0b10001,

                   0b10001,

                   0b00000,

                   0b00000};                                                                         

   byte Nalpha[8] ={0b00000,

                    0b10001,

                   0b11001,

                   0b10101,

                   0b10011,

                   0b10001,

                   0b00000,

                   0b00000};     

   byte Oalpha[8]={ 0b00000,

                     0b01110,

                     0b10001,

                     0b10001,

                     0b10001,

                     0b01110,

                     0b00000,

                     0b00000}; 

 byte Palpha[8]={  0b00000,

                      0b11100,

                     0b10010,

                     0b11100,

                     0b10000,

                     0b10000,

                     0b00000,

                     0b00000};      

 byte Ralpha[8]={    0b00000,

                     0b11110,

                     0b10001,

                     0b11110,

                     0b10100,

                     0b10010,

                     0b00000,

                     0b00000};                                    

 byte Salpha[8] ={ 0b00000,

                   0b01110,

                   0b10000,

                   0b01110,

                   0b00001,

                   0b01110,

                   0b00000,

                   0b00000}; 

   byte Talpha[8] ={0b00000,

                    0b11111,

                   0b00100,

                   0b00100,

                   0b00100,

                   0b00100,

                   0b00000,

                   0b00000};  

                                        

  byte Ualpha[8]={   0b00000,

                     0b10001,

                     0b10001,

                     0b10001,

                     0b10001,

                     0b01110,

                     0b00000,

                     0b00000};    

  byte Walpha[8] ={  0b00000,

                     0b10001,

                     0b10001,

                     0b10101,

                     0b11011,

                     0b10001,

                     0b00000,

                     0b00000};

   byte Yalpha[8]={  0b00000,

                     0b10001,

                     0b10001,

                     0b01010,

                     0b00100,

                     0b00100,

                     0b00000,

                     0b00000};   

    

  byte next[8]={0b00000,

                0b10000,

                0b01000,

                0b00100,

                0b01000,

                0b10000,

                0b00000,

                0b00000

              };                               


void setup()  {

   Wire.begin();

   rtc.begin();

   Serial.begin(9600); //Software serial initialization

   pinMode(b1, INPUT_PULLUP);

   pinMode(b2, INPUT_PULLUP);

   pinMode(b3, INPUT_PULLUP);

   pinMode(b4, INPUT_PULLUP);

   pinMode( buzzer, OUTPUT ); 

   digitalWrite( buzzer, LOW ); 

   lcd.begin(16,2);

   lcd.setCursor(0,0);

  

   lcd.print("SCHOOL BELL");

   delay(3000);

   if (! rtc.isrunning()) {

    Serial.println("RTC is NOT running!");

    // following line sets the RTC to the date & time this sketch was compiled

     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

   }

   delay(3000);

   lcd.clear();

lcd.setCursor(0,0);

lcd.print(" ENTER ALL INFO ");

lcd.setCursor(0,1);

lcd.print(" YES*       NO# ");

}


void loop() { 

bS1 = digitalRead(b1);

bS2 = digitalRead(b2);

bS3 = digitalRead(b3);

bS4 = digitalRead(b4); 


if(bS1==LOW){

      pos=20;

      DateTime now =rtc.now();

      prevTime=now.minute();

      prevHour=now.hour();

      Serial.println(prevHour);

      Serial.println(prevTime);

      Serial.println(EEPROM.read(4));

      lcd.clear();}

if(bS4==LOW){

     pos=30; 

     DateTime now =rtc.now();

     prevTime=now.minute();

     prevHour=now.hour();

     hoursE = EEPROM.read(4);//Period time delay

     Serial.println(prevHour);

     Serial.println(prevTime);

     Serial.println(EEPROM.read(4));

     lcd.clear();}

while(pos==20){

    pos=0;

    delay(1000);

    lcd.clear();

  while(pos==0){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print("ENTER START TIME");  

   if(bS1==LOW && pos==0){

    lcd.setCursor(5,1);

    starttime++;

    printDigits2(starttime);

    lcd.setCursor(8,1);

    lcd.print("O' clock");

    EEPROM.write(5,starttime);

    delay(200);

    if(starttime==24)

    starttime=0;

   }

   if(bS4==LOW && pos==0){

     prevHour=starttime;

     lcd.setCursor(0,0);

    lcd.print(" *****SAVED**** ");

     EEPROM.write(0,starttime);

     Serial.println(starttime);

     delay(1000);

     pos=1;

     lcd.clear();

     break;   

    }

  }

 while(pos==1){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print(" ENTER END TIME ");  

   if(bS1==LOW && pos==1){

    

    lcd.setCursor(5,1);

    endtime++;

    printDigits2(endtime);

    lcd.setCursor(7,1);

    lcd.print("O' clock");

    delay(200);

    if(endtime==24)

    endtime=0;

   }

   if(bS4==LOW && pos==1){

     lcd.setCursor(0,0);

    lcd.print(" *****SAVED**** ");

     EEPROM.write(1,endtime);

     Serial.println(endtime);

     delay(1000);

     pos=2;

     lcd.clear();

     break;   

    }

  }

  while(pos==2){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print(" FIRST BRK TIME ");  

   if(bS1==LOW && pos==2){

    lcd.setCursor(5,1);

    break1++;

    printDigits2(break1);

    lcd.setCursor(8,1);

    lcd.print("minutes");

    delay(200);

    if(break1==40)

    break1=0;

   }

   if(bS4==LOW && pos==2){

     lcd.setCursor(0,0);

    lcd.print(" *****SAVED**** ");

     EEPROM.write(2,break1);

     Serial.println(break1);

     delay(1000);

     pos=3;

     lcd.clear();

     break;   

    }

      }

 while(pos==3){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print("SECOND BRK TIME ");  

   if(bS1==LOW && pos==3){

    lcd.setCursor(5,1);

    break2++;

    printDigits2(break2);

    lcd.setCursor(8,1);

    lcd.print("minutes");

    delay(200);

    if(break2==40)

    break2=0;

   }

   if(bS4==LOW && pos==3){

     lcd.setCursor(0,0);

    lcd.print(" *****SAVED**** ");

     EEPROM.write(3,break2);

     Serial.println(break2);

     delay(1000);

     pos=4;

     lcd.clear();

     break;   

    }

  }

/*Slection of subject DAY wise*/ 

while(pos==4){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print("SLCT MONDAY SUB ");  

   if(bS1==LOW && pos==4){

    if(i>0){

      i--;

      delay(400);

    lcd.setCursor(6,1);

    lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

   if(bS2==LOW && pos==4){

    if(i<7){

         i++;

        delay(400);

        lcd.setCursor(6,1);

        lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

    if(bS4==LOW && pos==4){

      EEPROM.write(j+6,i);

      lcd.setCursor(0,0);

      lcd.print(" *****SAVED**** ");

      Serial.print(j+6);

      Serial.println(i);

      delay(1000);

      lcd.clear();

      j++;

   }

if(bS3==LOW && pos==4){

      lcd.setCursor(0,0);

      lcd.print("*SUB SAVED MON*");

      delay(1000);

      lcd.setCursor(0,1);

      lcd.print("   THANK YOU   ");

      pos=5;

       delay(3000);

       lcd.clear();

       break;

}    

  }

  /*Subject selection for TUESDAY*/

  while(pos==5){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print("SLCT TUESDAY SUB");  

  if(bS1==LOW && pos==5){

    if(i>0){

      i--;

      delay(400);

    lcd.setCursor(6,1);

    lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

   if(bS2==LOW && pos==5){

    if(i<7){

         i++;

        delay(400);

        lcd.setCursor(6,1);

        lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

    if(bS4==LOW && pos==5){

      EEPROM.write(j+7,i);

      lcd.setCursor(0,0);

      lcd.print(" *****SAVED**** ");

      Serial.print(j+7);

      Serial.println(i);

      delay(1000);

      lcd.clear();

      j++;

   }

if(bS3==LOW && pos==5){

      lcd.setCursor(0,0);

      lcd.print(" *SUB SAVED TUE* ");

      delay(1000);

      lcd.setCursor(0,1);

      lcd.print("    THANK YOU    ");

      pos=6;

      delay(3000);

      lcd.clear();

      break;

}    

  }

/*Subject selection for WEDNESDAY*/

while(pos==6){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print(" WEDNESDAY SUB ");  

   if(bS1==LOW && pos==6){

    if(i>0){

      i--;

      delay(400);

    lcd.setCursor(6,1);

    lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

   if(bS2==LOW && pos==6){

    if(i<7){

         i++;

        delay(400);

        lcd.setCursor(6,1);

        lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

    if(bS4==LOW && pos==6){

      EEPROM.write(j+7,i);

      lcd.setCursor(0,0);

      lcd.print(" *****SAVED**** ");

      Serial.print(j+7);

      Serial.println(i);

      delay(1000);

      lcd.clear();

      j++;

   }

if(bS3==LOW && pos==6){

      lcd.setCursor(0,0);

      lcd.print(" *SUB SAVED WED* ");

      delay(1000);

      lcd.setCursor(0,1);

      lcd.print("    THANK YOU    ");

      pos=7;

      delay(3000);

      lcd.clear();

      break;

}    

  }

 /*Subject selection for THUSDAY*/

while(pos==7){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print(" SLT THUSDAY SUB ");  

   if(bS1==LOW && pos==7){

    if(i>0){

      i--;

      delay(400);

    lcd.setCursor(6,1);

    lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

   if(bS2==LOW && pos==7){

    if(i<7){

         i++;

        delay(400);

        lcd.setCursor(6,1);

        lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

   if(bS4==LOW && pos==7){

      EEPROM.write(j+7,i);

      lcd.setCursor(0,0);

      lcd.print(" *****SAVED**** ");

      Serial.print(j+7);

      Serial.println(i);

      delay(1000);

      lcd.clear();

      j++;

   }

if(bS3==LOW && pos==7){

      lcd.setCursor(0,0);

      lcd.print(" *SUB SAVED THU* ");

      delay(1000);

      lcd.setCursor(0,1);

      lcd.print("    THANK YOU    ");

      pos=8;

      delay(3000);

      lcd.clear();

      break;

}    

  }
//Automatic school Bell project

 /*Subject selection for FRIDAY*/

while(pos==8){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print(" SLT FRIDAY SUB ");  

   if(bS1==LOW && pos==8){

    if(i>0){

      i--;

      delay(400);

    lcd.setCursor(6,1);

    lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

   if(bS2==LOW && pos==8){

    if(i<7){

         i++;

        delay(400);

        lcd.setCursor(6,1);

        lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

    if(bS4==LOW && pos==8){

      EEPROM.write(j+7,i);

      lcd.setCursor(0,0);

      lcd.print(" *****SAVED**** ");

      Serial.print(j+7);

      Serial.println(i);

      delay(1000);

      lcd.clear();

      j++;

   }

if(bS3==LOW && pos==8){

      lcd.setCursor(0,0);

      lcd.print(" *SUB SAVED FRI* ");

      delay(1000);

      lcd.setCursor(0,1);

      lcd.print("    THANK YOU    ");

      pos=9;

      delay(3000);

      lcd.clear();

      break;

}    

  } 

 /*Subject selection for SATURDAY*/

while(pos==9){

    bS1 = digitalRead(b1);

    bS2 = digitalRead(b2);

    bS3 = digitalRead(b3);

    bS4 = digitalRead(b4);

    lcd.setCursor(0,0);

    lcd.print("SLT SATURDAY SUB ");  

   if(bS1==LOW && pos==9){

    if(i>0){

      i--;

      delay(400);

    lcd.setCursor(6,1);

    lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

   if(bS2==LOW && pos==9){

    if(i<7){

         i++;

        delay(400);

        lcd.setCursor(6,1);

        lcd.print("      ");

    }

    lcd.setCursor(6,1);

    lcd.print(mySubject[i]);

   }

    if(bS4==LOW && pos==9){

      EEPROM.write(j+7,i);

      lcd.setCursor(0,0);

      lcd.print(" *****SAVED**** ");

      Serial.print(j+7);

      Serial.println(i);

      delay(1000);

      lcd.clear();

      j++;

   }

if(bS3==LOW && pos==9){

      lcd.setCursor(0,0);

      lcd.print(" *SUB SAVED SAT* ");

      delay(1000);

      lcd.setCursor(0,1);

      lcd.print("    THANK YOU    ");

      pos=30;

      delay(3000);

      lcd.clear();

      break;

}    

  }

   

 /*READING ALL THE DATA FROM THE INTERNAL EEPROM*/

  starttime = EEPROM.read(0);     

  endtime = EEPROM.read(1);

  break1 = EEPROM.read(2);

  break2 = EEPROM.read(3);

  hoursE = EEPROM.read(4);//Period time delay

  int totalbreak=break1+ break2;

  //totaltime=((endtime-starttime)*10 - totalbreak);

  totaltime=((endtime-starttime)*60-totalbreak);

  periodtime=totaltime/5;

  EEPROM.write(4,periodtime);

  Serial.println(EEPROM.read(4));

  pos=30; 

}

  while(pos==30){

  DateTime now =rtc.now();

  hoursH=EEPROM.read(0);//start time in hour 

  newHour = now.hour();

  newTime = now.minute();

//if(newHour == hoursH && newTime == 0){  

  if(newHour == hoursH && newTime <= 60){

     prevTime=now.minute();

     lcd.setCursor(0,0);

     lcd.print("CLASS STARTED  ");
     

     lcd.setCursor(0,1);

     lcd.print("                 "); 
     digitalWrite(7, HIGH);

     delay(2000);
     digitalWrite(7, LOW);

     delay(1000);

     lcd.clear();

     while(1){

      matchDAY(); 

  }

}

else{

  lcd.setCursor(0,0);

  lcd.print("  Waiting for...  ");

  lcd.setCursor(5,1);

  printDigits2(hoursH);

  lcd.setCursor(8,1);

  lcd.print("O' Clock");}

  }

}



void matchDAY(){

   DateTime now =rtc.now();

   //Monday subject display

while(now.dayOfTheWeek()== 1){

  currentTIME();

  matchTIM(); 

  

  value = EEPROM.read(monA);

  ALLDays(now.dayOfTheWeek());

  lcd.setCursor(0,0);

  lcd.print(mySubject[value]);

  if(noPeriod==2 && breakR==0){

  brk1=EEPROM.read(2);

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime == prevTime + brk1){

       prevTime=prevTime+brk1;

        Serial.print("Break1");

        Serial.println(prevTime);

        noPeriod=0;

        breakR=1;

        lcd.clear();

        break;

                  }

            }

      }

  if(noPeriod==1 &&  breakR==2){

     breakR=0;

     lcd.clear();

     endsession(); 

     while(1){

        //End of the session

     }

  }

  //hoursE
//Automatic school Bell project

  if(noPeriod==2 && breakR==1){

    brk2=EEPROM.read(3);//time delay

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    lcd.setCursor(11,0);

    printDigits2(newTime);

    printDigits2(now.second());

    if(newTime== prevTime + brk2){

      prevTime=prevTime+brk2;

        Serial.print("Break2");

        Serial.println(prevTime);

        noPeriod=0;

        breakR=2;

        lcd.clear();

        break;

                       }

            }

  }

  else{

    

     nextSUB = EEPROM.read(monA+1);

      ALLSubjects(9);

        if(noPeriod == 0 && breakR == 2)

          ALLSubjects(8);

       else

        ALLSubjects(nextSUB);

      }

  }   

  // Tuesday subject display

while(now.dayOfTheWeek()== 2){

  currentTIME();

  matchTIM();

  

  value = EEPROM.read(tueA);

  ALLDays(now.dayOfTheWeek());

  lcd.setCursor(0,0);

  lcd.print(mySubject[value]);

  if(noPeriod==2 && breakR==0){

  brk1=EEPROM.read(2);

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk1){

       prevTime=prevTime+brk1;

        Serial.print("Break1");

        Serial.println(prevTime);

        noPeriod=0;

        breakR=1;

        lcd.clear();

        break;

                   }

            }

      }

  if(noPeriod==1 &&  breakR==2){

     breakR=0;

     endsession(); 

     while(1){

        //End of the session

     }

  }

  if(noPeriod==2 && breakR==1){

    brk2=EEPROM.read(3);//time delay

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk2){

      prevTime=prevTime+brk2;

        Serial.print("Break2");

        Serial.println(prevTime);

       noPeriod=0;

        breakR=2;

        lcd.clear();

        break;

                       }

            }

  }

  else{

     nextSUB = EEPROM.read(tueA+1);

      ALLSubjects(9);

        if(noPeriod == 0 && breakR == 2)

          ALLSubjects(8);

       else

        ALLSubjects(nextSUB);

      }

  }

  

//Wednesday subject display

while(now.dayOfTheWeek()== 3){

  currentTIME();

   matchTIM(); 

  value = EEPROM.read(wedA);

  ALLDays(now.dayOfTheWeek());

  lcd.setCursor(0,0);

  lcd.print(mySubject[value]);

  if(noPeriod==2 && breakR==0){

  brk1=EEPROM.read(2);

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk1){

       prevTime=prevTime+brk1;

        Serial.print("Break1");

        Serial.println(prevTime);

        noPeriod=0;

        breakR=1;

        lcd.clear();

        break;

                        }

            }

      }

  if(noPeriod==1 &&  breakR==2){

     breakR=0;

     endsession(); 

     while(1){

        //End of the session

     }

  }

  if(noPeriod==2 && breakR==1){

    brk2=EEPROM.read(3);//time delay

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk2){

      prevTime=prevTime+brk2;

        Serial.print("Break2");

        Serial.println(prevTime);

       noPeriod=0;

        breakR=2;

        lcd.clear();

        break;

                       }

            }

  }

  else{

     nextSUB = EEPROM.read(wedA+1);

      ALLSubjects(9);

        if(noPeriod == 0 && breakR == 2)

          ALLSubjects(8);

       else

        ALLSubjects(nextSUB);

      }

  }


// Thusday subject display   

while(now.dayOfTheWeek()== 4){

  currentTIME();

  matchTIM(); 

  value = EEPROM.read(thuA);

  ALLDays(now.dayOfTheWeek());

  lcd.setCursor(0,0);

  lcd.print(mySubject[value]);

  if(noPeriod==2 && breakR==0){

  brk1=EEPROM.read(2);

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk1){

       prevTime=prevTime+brk1;

        Serial.print("Break1");

        Serial.println(prevTime);

        noPeriod=0;

        breakR=1;

        lcd.clear();

        break;

                        }

            }

      }

  if(noPeriod==1 &&  breakR==2){

     breakR=0;

     endsession(); 

     while(1){

        //End of the session

     }

  }

  if(noPeriod==2 && breakR==1){

    brk2=EEPROM.read(3);//time delay

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk2){

      prevTime=prevTime+brk2;

        Serial.print("Break2");

        Serial.println(prevTime);

       noPeriod=0;

        breakR=2;

        lcd.clear();

        break;

                       }

            }

  }

  else{

     nextSUB = EEPROM.read(thuA+1);

      ALLSubjects(9);

        if(noPeriod == 0 && breakR == 2)

          ALLSubjects(8);

       else

        ALLSubjects(nextSUB);

      }

  }


  

  //Friday subject display

while(now.dayOfTheWeek()== 5){

  currentTIME();

   matchTIM(); 

  value = EEPROM.read(friA);

  ALLDays(now.dayOfTheWeek());

  lcd.setCursor(0,0);

  lcd.print(mySubject[value]);

  if(noPeriod==2 && breakR==0){

  brk1=EEPROM.read(2);

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk1){

       prevTime=prevTime+brk1;

        Serial.print("Break1");

        Serial.println(prevTime);

        noPeriod=0;

        breakR=1;

        lcd.clear();

        break;

                        }

            }

      }

  if(noPeriod==1 &&  breakR==2){

     breakR=0;

     endsession(); 

     while(1){

        //End of the session

     }

  }

  if(noPeriod==2 && breakR==1){

    brk2=EEPROM.read(3);//time delay

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk2){

      prevTime=prevTime+brk2;

        Serial.print("Break2");

        Serial.println(prevTime);

       noPeriod=0;

        breakR=2;

        lcd.clear();

        break;

                       }

            }

  }

  else{

     nextSUB = EEPROM.read(friA+1);

      ALLSubjects(9);

        if(noPeriod == 0 && breakR == 2)

          ALLSubjects(8);

       else

        ALLSubjects(nextSUB);

      }

  }


  

  //Saturday subject display

while(now.dayOfTheWeek()== 6){

  currentTIME();

   matchTIM(); 

  value = EEPROM.read(satA);

  ALLDays(now.dayOfTheWeek());

  lcd.setCursor(0,0);

  lcd.print(mySubject[value]);

  if(noPeriod==2 && breakR==0){

  brk1=EEPROM.read(2);

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk1){

       prevTime=prevTime+brk1;

        Serial.print("Break1");

        Serial.println(prevTime);

        noPeriod=0;

        breakR=1;

        lcd.clear();

        break;

                        }

            }

      }

  if(noPeriod==1 &&  breakR==2){

     breakR=0;

     endsession(); 

     while(1){

        //End of the session

     }

  }

  if(noPeriod==2 && breakR==1){

    brk2=EEPROM.read(3);//time delay

    lcd.setCursor(0,0);

    lcd.print("***BREAK TIME***");

   while(1){

    currentTIME();

    if(newTime== prevTime + brk2){

      prevTime=prevTime+brk2;

        Serial.print("Break2");

        Serial.println(prevTime);

       noPeriod=0;

        breakR=2;

        lcd.clear();

        break;

                       }

            }

  }

  else{

     nextSUB = EEPROM.read(satA+1);

      ALLSubjects(9);

        if(noPeriod == 0 && breakR == 2)

          ALLSubjects(8);

       else

        ALLSubjects(nextSUB);

      }

  }

}




void currentTIME(){

 lcd.setCursor(6,1);

 lcd.print("  ");

 DateTime now = rtc.now();

 lcd.setCursor(8,1);

 printDigits2(HOUR=now.hour()); 

 lcd.print(":");

 newHour=now.hour();

 printDigits2(MINUT=now.minute());

 lcd.print(":");

 newTime = now.minute();

 printDigits2(SECOND=now.second());


 delay(800);

 currentDAY();

 delay(800);

}


void currentDAY(){

 DateTime now = rtc.now();

 lcd.setCursor(6,1);

 printDigits2(now.day());

 lcd.print("/");

 printDigits2(now.month());

 lcd.print("/");

 lcd.print(now.year(),DEC);


}



void matchTIM(){

  DateTime now =rtc.now(); 

 int tempTime = prevTime + hoursE;

 if(tempTime >=60){

  tempTime = tempTime - 60;   

 }

 else 

 tempTime = prevTime + hoursE; 

if(newTime == tempTime){

   prevTime=now.minute();

   Serial.print("MatchTime");

   Serial.println(prevTime);

   if(now.dayOfTheWeek()==1){

   digitalWrite( buzzer, HIGH );

   delay(3000);

   digitalWrite( buzzer, LOW );

   monA++;

   noPeriod++;

   lcd.setCursor(0,0);

   lcd.print("                 "); 

   }

   if(now.dayOfTheWeek()==2){

    digitalWrite( buzzer, HIGH );

   delay(3000);

   digitalWrite( buzzer, LOW );

   tueA++;

   noPeriod++;

   lcd.setCursor(0,0);

   lcd.print("                 "); 

   }

  if(now.dayOfTheWeek()==3){

    digitalWrite( buzzer, HIGH );

   delay(3000);

   digitalWrite( buzzer, LOW );

   wedA++;

   noPeriod++;

  lcd.setCursor(0,0);

   lcd.print("                 "); 

   }

   if(now.dayOfTheWeek()==4){

    digitalWrite( buzzer, HIGH );

   delay(3000);

   digitalWrite( buzzer, LOW );

   thuA++;

   noPeriod++;

   lcd.setCursor(0,0);

   lcd.print("                 "); 

   } 

   if(now.dayOfTheWeek()==5){

    digitalWrite( buzzer, HIGH );

   delay(3000);

   digitalWrite( buzzer, LOW );

   friA++;

   noPeriod++;

   lcd.setCursor(0,0);

   lcd.print("                 "); 

   }

   if(now.dayOfTheWeek()==6){

    digitalWrite( buzzer, HIGH );

   delay(3000);

   digitalWrite( buzzer, LOW );

   satA++;

   noPeriod++;

   lcd.setCursor(0,0);

   lcd.print("                 "); 

   }

}

}


//this void function is really useful; it adds a "0" to the beginning of the number, 

//so that 5 minutes is displayed as "05", rather than "5 "

void printDigits2(int digits)  

{

  if(digits < 10) 

  {

    lcd.print("0");

    lcd.print(digits);

  }

  else

  {

    lcd.print(digits);

  }

}

//Automatic school Bell project

//char* mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"};

void ALLSubjects(int sub)

{

  switch(sub)

  {

    case 0:

          lcd.createChar(1,Malpha);

          lcd.createChar(2,Aalpha);

          lcd.createChar(3,Talpha);

          lcd.createChar(4,Halpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);

          lcd.setCursor(2,1);

          lcd.write(3);

          lcd.setCursor(3,1);

          lcd.write(4);break;

    case 1: 

          lcd.setCursor(0,1);

          lcd.write("     ");

          delay(50);

          lcd.createChar(1,Ealpha);

          lcd.createChar(2,Nalpha);

          lcd.createChar(3,Galpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);

          lcd.setCursor(2,1);

          lcd.write(3);break;

 //char* mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"};         

    case 2: 

          lcd.setCursor(0,1);

          lcd.write("     ");

          delay(50);

          lcd.createChar(1,Balpha);

          lcd.createChar(2,Ialpha);

          lcd.createChar(3,Oalpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);

          lcd.setCursor(2,1);

          lcd.write(3);break;

    case 3:

          lcd.setCursor(0,1);

          lcd.write("     ");

          delay(50);

          lcd.createChar(1,Palpha);

          lcd.createChar(2,Halpha);

          lcd.createChar(3,Yalpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);

          lcd.setCursor(2,1);

          lcd.write(3);break;

 //char* mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"};

    case 4: 

          lcd.setCursor(0,1);

          lcd.write("     ");

          delay(50);

          lcd.createChar(1,Calpha);

          lcd.createChar(2,Halpha);

          lcd.createChar(3,Ealpha);

          lcd.createChar(4,Malpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);

          lcd.setCursor(2,1);

          lcd.write(3);

          lcd.setCursor(3,1);

          lcd.write(4);break;

          

    case 5: 

          lcd.createChar(1,Ialpha);

          lcd.createChar(2,Talpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);break;

          

    case 6: 

          lcd.setCursor(0,1);

          lcd.write("     ");

          delay(50);

          lcd.createChar(1,Halpha);

          lcd.createChar(2,Ialpha);

          lcd.createChar(3,Salpha);

          lcd.createChar(4,Talpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);

          lcd.setCursor(2,1);

          lcd.write(3);

          lcd.setCursor(3,1);

          lcd.write(4);break;

 //char* mySubject[]={"MATHS", "ENG","BIO","PHY","CHEM","IT LAB","HIST","GEO"};

    case 7: 

          lcd.setCursor(0,1);

          lcd.write("     ");

          delay(50);

          lcd.createChar(1,Galpha);

          lcd.createChar(2,Ealpha);

          lcd.createChar(3,Oalpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);

          lcd.setCursor(2,1);

          lcd.write(3);break;

   case 8: 

          lcd.setCursor(0,1);

          lcd.write("     ");

          delay(50);

          lcd.createChar(1,Ealpha);

          lcd.createChar(2,Nalpha);

          lcd.createChar(3,Dalpha);

          lcd.setCursor(0,1);

          lcd.write(1);

          lcd.setCursor(1,1);

          lcd.write(2);

          lcd.setCursor(2,1);

          lcd.write(3);break;       

   case 9: 

          lcd.createChar(8,next);

          lcd.setCursor(5,1);

          lcd.write(8);

          delay(1000);

          lcd.setCursor(5,1);

          lcd.write(" ");

          delay(1000);break;

  default:break;

  } 

}


void ALLDays(int dey)

{

  switch(dey)

  {

    case 0://sun

          lcd.createChar(5,Salpha);

          lcd.createChar(6,Ualpha);

          lcd.createChar(7,Nalpha);

          lcd.setCursor(7,0);

          lcd.write(5);

          lcd.setCursor(8,0);

          lcd.write(6);

          lcd.setCursor(9,0);

          lcd.write(7);var=1;break;   

       case 1://mon

          lcd.createChar(5,Malpha);

          lcd.createChar(6,Oalpha);

          lcd.createChar(7,Nalpha);

          lcd.setCursor(7,0);

          lcd.write(5);

          lcd.setCursor(8,0);

          lcd.write(6);

          lcd.setCursor(9,0);

          lcd.write(7);var=2;break;

      case 2://tue

          lcd.createChar(5,Talpha);

          lcd.createChar(6,Ualpha);

          lcd.createChar(7,Ealpha);

          lcd.setCursor(7,0);

          lcd.write(5);

          lcd.setCursor(8,0);

          lcd.write(6);

          lcd.setCursor(9,0);

          lcd.write(7);var=3;break;

    

    case 3://wed

          lcd.createChar(5,Walpha);

          lcd.createChar(6,Ealpha);

          lcd.createChar(7,Dalpha);

          lcd.setCursor(7,0);

          lcd.write(5);

          lcd.setCursor(8,0);

          lcd.write(6);

          lcd.setCursor(9,0);

          lcd.write(7);var=4;break;

    case 4://thu

          lcd.createChar(5,Talpha);

          lcd.createChar(6,Halpha);

          lcd.createChar(7,Ualpha);

          lcd.setCursor(7,0);

          lcd.write(5);

          lcd.setCursor(8,0);

          lcd.write(6);

          lcd.setCursor(9,0);

          lcd.write(7);var=5;break;

     case 5://fri

          lcd.createChar(5,Falpha);

          lcd.createChar(6,Ralpha);

          lcd.createChar(7,Ialpha);

          lcd.setCursor(7,0);

          lcd.write(5);

          lcd.setCursor(8,0);

          lcd.write(6);

          lcd.setCursor(9,0);

          lcd.write(7);var=6;break;

      case 6://sat

          lcd.createChar(5,Salpha);

          lcd.createChar(6,Aalpha);

          lcd.createChar(7,Talpha);

          lcd.setCursor(7,0);

          lcd.write(5);

          lcd.setCursor(8,0);

          lcd.write(6);

          lcd.setCursor(9,0);

          lcd.write(7);var=7;break;    

      default:break;

  } 

}


void endsession(){

   lcd.setCursor(0,0);

   lcd.print("   Session End  ");

   lcd.setCursor(0,1);

   lcd.print("   Good Luck :) ");

  delay(3000);

}

Before Uploading this Final Code , we need to examine our all components and coding if they are working or not.

so, first of all we need to check the RTC module and set the time and date.

RTC module set time and date Arduino Code

#include "Arduino.h"
#include "uRTCLib.h"

// uRTCLib rtc;
uRTCLib rtc(0x68);

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup() {
  Serial.begin(9600);
  delay(3000); // wait for console opening

  URTCLIB_WIRE.begin();

  // Comment out below line once you set the date & time.
  // Following line sets the RTC with an explicit date & time
  // for example to set January 13 2022 at 12:56 you would call:
   rtc.set(0, 57, 10 , 2, 12, 2, 24);
  // rtc.set(second, minute, hour, dayOfWeek, dayOfMonth, month, year)
  // set day of week (1=Sunday, 7=Saturday)
}

void loop() {
  rtc.refresh();

  Serial.print("Current Date & Time: ");
  Serial.print(rtc.year());
  Serial.print('/');
  Serial.print(rtc.month());
  Serial.print('/');
  Serial.print(rtc.day());

  Serial.print(" (");
  Serial.print(daysOfTheWeek[rtc.dayOfWeek()-1]);
   Serial.print(") ");

  Serial.print(rtc.hour());
  Serial.print(':');
  Serial.print(rtc.minute());
  Serial.print(':');
  Serial.println(rtc.second());
  
  delay(1000);
}

After setting the time in RTC module and testing. we need to check the push button Are working or not.you can upload this code using Arduino iDE. Automatic school Bell project By using Arduino is very simple with the RTC module.

Push button testing code

void setup() {
  // put your setup code here, to run once:
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
int m = digitalRead(A0);
int n = digitalRead(A1);
int o = digitalRead(A2);
int p = digitalRead(A0);
Serial.print(m);
Serial.print("   ");
Serial.print(n);
Serial.print("   ");
Serial.print(o);
Serial.print("   ");
Serial.println(p);
//Serial.print("   ");
}

Afteer uploading this push button test code we need to check the pushbuttons are working not. for this we need to open the serial monitor and test our button button by pressing them. if there is 0 comes by pushing the push button it means the push buttons are working. Now we test the Display and Relay – bell code in Arduino based Automatic school Bell project.

16X2 Display testing Code.

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 13, en = 12, d4 = 6, d5 = 5, d6 = 4, d7 = 3;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

Now it’s time to check the Bell code and bell connections.

void setup()
{
pinMode(7, OUTPUT);
}
void loop()
{
digitalWrite(7, HIGH);
delay(3000);
digitalWrite(7, LOW);
delay(3000);
}

all these code for troubleshooting if our final code is not working we can check things separately. if they are working or not. still you face any problem you can ask in the comment section.

Leave a Comment