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.
The following two tabs change content below.
Raisy Clutch
Am from Uganda. Fond of Electronics and Animation. And I dance
Raisy Clutch

Latest posts by Raisy Clutch (see all)

Ask your query

avatar
  Subscribe  
Notify of