Automatic school bell system using Arduino

With everything getting automated these days I think it’s only fair to give good old school bell a touch of automation. So I thought to design and develop Automatic school bell system using Arduino development board. This system activates the School bell at predefined time each day. Add this project comes with a manual switch to activate the bell. This will give the liberty to the user to activate it manually when required.

SCHEMATIC DESIGN OF AUTOMATIC SCHOOL BELL SYSTEM:

automatic-school-bell-system-arduino

DS1307 RTC MODULE:

DS1307 is an Real time clock chip that is used in many Embedded applications for adding real time to the system. Timing generated using Microcontroller delays are not precise as real time so when comes to time sensitive applications like Alarms, Timers usage of RTC chips is very much necessary. This RTC chip will communicate with Arduino using I2C communication protocol to provide real time input. Arduino can use this real time input to perform the desired operation, in our case it’s ringing of School bell.

WORKING OF AUTOMATIC BELL PROJECT:

The working of this Automatic School bell system starts with Real time clock module DS1307. This module feeds Arduino with real time and keeps track of it. Through the process of polling Arduino will frequently get the time and date values from this chip. Also user has been given five button inputs which they can use to set the Hours, minutes, Date, month and year in the RTC chip. Continuous toggle of these buttons will vary the corresponding values and register them in RTC chip. The automatic bell timer is activated by means of a Relay which is controlled via a transistor switch. The transistor switch is very much necessary since Arduino cannot source enough current to operate the relay directly. Adding a flywheel diode D1 will act as a protection to the rest of circuit when the relay is turned OFF.

CODE:

I have commented the code almost every line for better understanding and the coding part is pretty simple as well.

#include <LiquidCrystal.h>
#include <DS1307.h>
#include <Wire.h>

LiquidCrystal lcd(13,12,11,10,9,8); /* lcd pinouts initialising */
int datetime[7]; /* stores the Time and date values */

/* setting up the input pins */
void setup(){
  for(int i=3;i<8;i++){
     pinMode(i,INPUT); 
  }
  pinMode(2,OUTPUT); /* pin for the bell */
  lcd.begin(20,2); /* powering up the lcd */
  DS1307.begin(); /* the Real Time datetime Module */
  DS1307.setDate(19,3,19,0,9,59,50);//d,m,y,sem,h,m,s - sets the time and date


}

// this will run forever till you die or till power goes off
void loop(){
    
DS1307.getDate(datetime); /* get date */

lcd.setCursor(0,1); /* move the cursor down */
lcd.print("Time: ");
Print(datetime[4]); /* print hour on the lcd */
lcd.print(":");
Print(datetime[5]); /* print minute */
lcd.print(":");
Print(datetime[6]); /* print seconds */
lcd.setCursor(0,0); /* move cursor back ontop */
lcd.print("Date: ");
Print(datetime[1]); /* day */
lcd.print("/");
Print(datetime[2]); /* month */
lcd.print("/");
lcd.print("20"); /* add 20 to it making it 2019 */
Print(datetime[0]); /* Print Year */


/* validating minutes, seconds and months for LCD printing and to avoid errors */
if(digitalRead(7)){
 datetime[5]++;
 if(datetime[5]>59) datetime[5]=0;  /* if minute is 59 */
 DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
 while(digitalRead(7));
}

if(digitalRead(6)){
 datetime[4]++;
 if(datetime[4]>23) datetime[4]=0; /* if hour has reached 24, making it 24 hours max */
 DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
 while(digitalRead(6));
}

if(digitalRead(5)){
 datetime[2]++;
 if(datetime[2]>28&&datetime[1]==2) datetime[2]=1; /* Setting the days in a month */
 else if(datetime[2]>30&&(datetime[1]==4||datetime[1]==6||datetime[1]==9||datetime[1]==11)) datetime[2]=1;
 else if(datetime[2]>31) datetime[2]=1;
 DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
 while(digitalRead(5));
}

if(digitalRead(4)){
 datetime[1]++;
 if(datetime[1]>12) datetime[1]=1; /* if 12 months reached */
 DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
 while(digitalRead(4));
}

if(digitalRead(3)){
 datetime[0]++;
 if(datetime[0]>99) datetime[0]=0; /* Years */
 DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
 while(digitalRead(3));
}

/* give it some time */
delay(100); 
/* checking the time to sound the bell */
if(datetime[4]==10 && datetime[5]==00){
  
  digitalWrite(2, HIGH); /* sound the bell */
  delay(10000);  /* let it ring for 10 seconds */
  digitalWrite(2, LOW);  /* mute the bell */
}

if(datetime[4]==11 && datetime[5]==00)
{ digitalWrite(2, HIGH); /* sound the bell */ 
delay(10000); /* let it ring for 10 seconds */ 
digitalWrite(2, LOW); /* mute the bell */ }

if(datetime[4]==12 && datetime[5]==00)
{ digitalWrite(2, HIGH); /* sound the bell */ 
delay(10000); /* let it ring for 10 seconds */ 
digitalWrite(2, LOW); /* mute the bell */ }
/*Repeat the above four lines of code with altered Hours and Minute values to make the bell ring for more time periods */
}

/* convert array to a value that can be displayed on the LCD */
void Print(int number){
lcd.print(number/10);
lcd.print(number%10);
}

NOTE:

  • You need too look for the current rating of your electric Bell and choose the Relay and switching transistor accordingly.
  • Keep this unit hidden and limited to be used by authorized personal.
  • Repeat the four lines of code from 84 to 89 and use it with altered hours and minutes values for more time period.

12
Ask your query

avatar
3 Comment threads
9 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
10 Comment authors
GiordanhsRaisy ClutchFrank Donaldsatish kadamsteve Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
satish kadam
Guest
satish kadam

we have already include all required libraries. although library error is present in this code

Frank Donald
Admin

Give me the key information about the error.

Raisy Clutch
Guest
Raisy Clutch

are you sure you copied the right code, use visual code for better debugging, and inclide the libraries in the arduino default library folder, https://github.com/jarzebski/Arduino-DS1307

sid amale
Guest
sid amale

hello bhai program uploding mai error aaa raha hai

Anonymous
Guest
Anonymous

Arduino: 1.8.8 (Windows 8.1), Board: “Arduino/Genuino Uno” Build options changed, rebuilding all E:\Arduino Programs\bel\bel.ino: In function ‘void setup()’: bel:13:9: error: expected unqualified-id before ‘.’ token DS1307.begin(); /* the Real Time datetime Module */ ^ bel:14:9: error: expected unqualified-id before ‘.’ token DS1307.setDate(19,3,19,0,9,59,50);//d,m,y,sem,h,m,s – sets the time and date ^ E:\Arduino Programs\bel\bel.ino: In function ‘void loop()’: bel:19:7: error: expected unqualified-id before ‘.’ token DS1307.getDate(datetime); /* get date */ ^ bel:39:8: error: expected unqualified-id before ‘.’ token DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */ ^ bel:45:8: error: expected unqualified-id before ‘.’ token DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */ ^… Read more »

Anonymous
Guest
Anonymous

how to slove it

steve
Guest
steve

same error here

Frank Donald
Admin

Check whether you have installed DS1307 library. I suspect that’s the cause of this error.

Raisy Clutch
Guest
Raisy Clutch

download the DS1307 Library, and put it in your aduino library folder, your project should compile without any errors https://github.com/jarzebski/Arduino-DS1307

Anthimos Aggelidis
Guest
Anthimos Aggelidis

Hello there i want to make a school bell for my classroom, i want to make it to ring from Monday to Friday for example at 7:30 then after 45minute a brake and after the next hour. etc… But also if i want to ring it manual!!! And stop it and start it again if i want !!!! Could you please tell me the parts and the ring bell i think for 220v bell to out it on wall power supply. Also could you tell me the code to upload it in the Arduino. And the diagram

Shehzad Taj
Guest
Shehzad Taj

hi dear i can help you for this task

Giordanhs
Guest
Giordanhs

Anthimos, Have you succesfully built your school bell??