Automatic School Bell using Arduino, DS1307 and 16×2 LCD

(Last Updated On: July 27, 2020)

Automatic School Bell

Automatic School Bell Introduction:

Automatic School Bell using Arduino, DS1307 and 16×2 LCD– In this tutorial, you will learn how to make an Automatic School Bell for a School or College. This Automatic School Bell project is based on the Arduino Uno, Real-time clock “RTC DS1307”, 16×2 LCD, Push buttons, and a Buzzer. The same project can also be developed using the Arduino Mega and Arduino Nano.

If you are a beginner and you have a little knowledge of Arduino boards, 16×2 LCD, and RTC “Real time clock”; then I highly recommend read the following articles.

Arduino Uno Vs Arduino Nano Vs Arduino Mega

This article will really help you in understanding all the three Arduino boards. In this article I have explained the Pinout and technical specifications. Moreover, after reading this article you will be able to decide which Arduino board should be used.

Getting Started with the Arduino IDE

The Arduino integrated development environment is a cross-platform application that is written in the programming language Java. It is used to write and upload programs to the Arduino board. It can run on Windows, Mac OS X, and Linux. In this tutorial I have explained all the basics things, including how to define variables, and how to start programming using the Arduino IDE. You can find different versions of the Arduino IDE, but I recommend you should download the latest version of the Arduino IDE. You can Download the Latest Version of the Arduino IDE by clicking on the Download Button below.

Download: Latest Version of the Arduino IDE 

16×2 LCD

In this tutorial, I have explained everything about the 16×2 LCD including the 16×2 LCD pinout, technical specifications, its interfacing with the Arduino, and how to write a very basic Arduino program to display text on the 16×2 LCD.

RTC DS3231:

Unlike the RTC DS1307 we have another type of the RTC which is DS3231 quite popular and is used frequently in Arduino based projects. I have a very detailed getting started tutorial on the RTCDS3231 which explains all the basics. The DS1307 is just like the RTC DS3231. You can start with this basic tutorial to understand how to read date and time information and then print it on the 16×2 LCD.

Trust me if you read all the above 4 articles, I don’t think so you will face any problem in building any type of automatic system. These articles will really help you in making this Automatic School Bell using Arduino.

Without any further delay, let’s get started!!!

Amazon Purchase Links:

Arduino Uno:

RTC DS1307

16×2 LCD

12V SPDT Relay module 1 channel


Check more electronic components on the Amazon store given above.

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Why Automatic School Bell?

I still remember my school and college days and I am sure you too remember.  In almost 90% school and colleges the classes are organized in periods. A school period is a block of time allocated for lessons, classes in schools. They typically last between 30 and 60 minutes, with around 3-10 periods per school day.

The ringing of a school bell is a signal that tells a school’s students when it is time to go to class in the morning or afternoon and when it is time to change classes during the day as well as when students are dismissed from school.

A teacher typically rang a handheld bell to signal students to come inside or to begin and end class; it may be used for other purposes such as getting students’ attention for special announcements. The first bells are believed to be from the 3rd century BC and were made of pottery.

Conventionally, the school bell is rang by a peon or multi-tasking assistant. What if there would be a microcontroller based automatic school bell which rings itself according to a fed timetable. This project is the implementation of same functionality.

This project is an Arduino Uno based Automatic School Bell which can be easily configured for every class of the School or college. We are going to assume that the School has a total of 5 periods organized in a day for different subjects and have two breaks in between. After the fifth period, the school is over.

In this project the programming is done in a way that the user is allowed to set the duration for each period and assign subject from a list. The user can also set the timetable for six days of the week from Monday to Saturday.

This Automatic School Bell should be installed in individual classrooms and the time table is set manually. The present day of the Week and current subject of the period are displayed on the first row of the 16×2 LCD, while the Date and Time along with the subject of the next period is displayed on the second row of the 16×2 LCD.

This project is also provided with the buzzer which is controlled using a 1 channel 12V SPDT type relay module. This allows the user to use different types of buzzers. This buzzer rings at the beginning and end of each period. The duration of each period and selection of the subject can be made through a four Push Buttons on the circuit. The project utilizes an RTC DS1307 Real Time Clock module to keep track of real-time date and time. The Automatic School Bell project is powered using a 12V adaptor.

About the RTC DS1307:

Automatic School Bell

RTC DS1307 Description:

This is Tiny RTC Time Clock DS1307 I2C IIC Module for Arduino. It contains a DS1307 Real-Time clock IC. DS1307 one of the easiest to use RTCs out there, with Arduino and other libraries or simply use I2C commands to set and retrieve the time and date. Includes a lithium coin cell battery which should be good for four years at least.

Along with the DS1307 real-time clock, the module also has an Atmel 24C32 EEPROM chip which is handy for storing data without worrying about power loss. There is also space on the board to solder your own DS18B20 temperature sensor.

This battery backup option allows you to keep a reasonably accurate time even when your Arduino is powered off. It is very useful in data logging and other time-sensitive applications. The device uses I2C to communicate with your Arduino.

DS1307 Features:

  1. Two-wire I2C interface
  2. Hour:Minutes:Seconds AM/PM
  3. Leap year compensation
  4. Accurate calendar up to the year 2100
  5. Consume less than 500nA in Battery-Backup
  6. 1Hz output pin
  7. 56 Bytes of Non-volatile memory available to the user
  8. 4KB of serial electrically erasable and programmable read-only memory (EEPROM)
  9. Embed DS18B20 temperature sensor interface with the pull-up resistor.

Arduino based Automatic School Bell Circuit Diagram:

Automatic School Bell

The circuit diagram of the Automatic School Bell system is very simple. Let’s start with the 4 push buttons. Each Push button is connected in series with a 10K ohm resistor. This is a Pullup resistor. When the push button is not pressed 5Volts are available at the controller pin. When the push button is pressed the ground is given as the signal to the Arduino’s I/O pin. Push Buttons1 to Push Buttons4 are connected with the Arduino’s Analog Pins A0 to A3.

The RTC DS1307 has a built-in button cell that allows keeping track of real-time irrespective of the power supply. For interfacing with the Arduino board, SDA and SCL pins of the RTC are connected to the SDA (Pin A4) and SCL (Pin A5) pins of the Arduino Uno board.

On the top is the 5V regulated power supply based on the famous LM7805 Linear Voltage Regulator. J1 is the Dc female power jack and this is where we connect the 12V adaptor or a 12V battery. The DC Female power jack J1 is further connected with the input and Gnd legs of the LM7805 voltage regulator. Two 470uF capacitors are connected at the input and output sides of the voltage regulator. The advantage of using 12Volts adaptor or a 12V battery is that, we get 12Volts and the regulated 5Volts. 12volts can be used to power up the Relay while the 5Volts can be used to power up the Arduino or other 5 volts electronics. You can connect a wire from the output of the LM7805 with the Vin pin of the Arduino Uno.

The 16X2 LCD display is used to display the messages prompting to input time-table information. It is connected to the Arduino Uno board by connecting its data pins to pins 3 to 6 of the Arduino Uno board. The RS and E pins of the 16×2 LCD are connected to pins 13 and 12 of the Arduino Uno respectively. The RW pin of the LCD is grounded. The CONTR “contrast” pin of the LCD is connected with the middle leg of the 10K ohm potentiometer. This potentiometer is used to control the contrast of the LCD. Pin number 1 and pin number 16 of the LCD are connected with the ground while the pins 2 and 15 are connected with the 5 volts.

On the right side you can see a 12V 1-channel relay module of the type SPDT. You can use a readymade relay module or you can build the one by yourself by following these connections. As this is a 12V relay that’s why one side of the relay coil is connected with the 12volts while the other side of the relay coil is connected with the collector of the 2n2222 NPN transistor. The emitter of the transistor is connected with the ground. The base of the 2n2222 NPN transistor is connected with the 10k resistor. The 10k resistor is connected with the Arduino’s pin number 2. A freewheeling diode is connected across the relay coil pins, and this is used against back EMF. The Buzzer will be connected between the common and normally open legs of the relay.

Automatic School Bell Arduino Programming:

Automatic School Bell Arduino Code Explanation:

First of all the required libraries are imported like the wire.h for virtual serial communication, EEPROM.h for internal memory management, RTClib.h for handling RTC module, LiquidCrystal.h for LCD messages, Keypad.h for handling keypad inputs and SoftwareSerial.h for serial communication.

An object lcd of LiquidCrystal type is declared and mapped to Arduino pins and thereafter an object of RTC class is instantiated. An array holding the names of subjects is declared and another array holding the names of day is declared. An array to hold duration of subject periods and break durations is declared and a variable to represent buzzer is declared. The switches forming the keypad are represented by b1, b2, b3 and b4 variables and default LOW logic to be passed to the switches is declared assigning 0 to bs1, bs2, bs3 and bs4 variables. The variables to hold start time of school, end-time of school, period duration, break duration and other counter variables are declared. Finally, bitmaps to store custom characters for display on LCD are defined.

A setup function is called in which the virtual serial communication is initiated and the RTC object is also initialized. The baud rate for data transmission to the LCD module is set to 9600 bits per second using Serial.begin() function. The keypad buttons are set digital input and pin connecting buzzer is set digital output and is set to LOW by default. Some initial messages are displayed on LCD and RTC is checked if running. A message to enter time-table is prompted on the display in the end of the setup function.

The input from the four keypad switches is read using digitalRead() function and relevant messages according to determined time-table setting wizard are displayed on the LCD. With each input, the fed information is either updated or saved in the appropriate variables. The progress of the wizard is tracked by a variable pos which is updated in each step.

Once the time-table for Monday to Saturday is fed by the user, the information is saved to EEPROM and compared with real-time date-time information of the RTC to activate buzzer and update subject information on the LCD display.

Working of the Automatic School Bell Project

Arduino based Automatic School Bell System Circuit Working

When the circuit is powered on, it prompts to input the school time-table. The user can initiate the process of feeding time-table information by pressing Right button. The user is first prompted to enter the start time of the school day and then duration of periods which is in hours. The duration of period can be incremented by pressing Up/Left button. Once the information is fed, user has to press save button to get it saved in the internal memory of Arduino Mega.

Next the user has to input the duration of first break in minutes in the similar manner. Then, user has to input duration of second break in minutes similarly. This is followed by selection of subjects for the five periods. This information is for Monday.

To skip to next day Exit After Saving button should be pressed. Once the time-table for all the six days of week are input to the internal memory of Arduino board, on pressing the Exit After Saving button for the sixth time, the LCD display starts showing the present day of the week and current subject of the period on first row and date and time along with subject of the next period on its second row.

The Arduino board compares the input timetable with the date and time information fetched from the RTC module. The date, day, time, subject of the current period and subject of the next period are displayed on the 16X2 LCD screen. Whenever the time instance of beginning of period or break is matched true with the time read from the RTC module, the Arduino program set the digital output at pin 2 to HIGH causing the buzzer to start buzzing.

The time, current subject and next subject information is updated on the LCD display on the end of each period or break.

Check out the Arduino sketch to learn how Arduino display time-table setting wizard and takes input from the keypad switches, stores time-table info in its internal memory, fetches time from RTC and compare RTC time with time-table to start buzzer and update information on LCD display.

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply