In any school, the classes are organized in periods and beginning of a period or break is alerted to the students and teachers by ringing the school bell. 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.
The project is an Arduino Mega based automatic bell system which can be configured for every class of the school. It is assumed that the school has five periods organized in a day for different subjects and have two breaks in between. The first break occurs after two periods and the next break occurs after the next two periods. After the fifth period, the school is over. The project allows to set duration for each period and assign subject from a list of subjects to each period. The user can set the time-table for six days of the week from Monday to Saturday. The user can also set the duration of both the periods.
The project device should be installed in individual classrooms and have the time table set manually. It has a 16X2 LCD display which keeps on displaying 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 circuit has a buzzer which starts humming at the beginning and end of each period or break. The duration of each period and selection of the subject can be made through a four switch keypad on the circuit. The project utilizes an RTC module to keep track of real date and time. The project device is line powered which is regulated by a step-down transformer, full-bridge rectifier and 7805 and 7812 voltage regulator ICs.
The functions of storing day-wise school time-table, duration and subjects of the periods, fetching date-time information from RTC module, displaying date-time, subject and day information on LCD module and activating buzzer according to the time table are managed by the Arduino Sketch. The Arduino program is written on Arduino IDE and burnt to the board using AVR Dude.
Components Required –
• Arduino Mega 2560 – 1 pc
• RTC module – DC1307 – 1pc
• 16X2 LCD – 1 pc
• 1K ohm resistors -3 pcs
• Push to ON switch – 4 pcs
• Voltage regulator -7805 and 7812
• 5V Buzzer
Block Diagram –
Fig. 1: Block Diagram of Arduino based Automatic School Bell System
Circuit Connections –
Fig. 2: Prototype of Arduino based Automatic School Bell System
The circuit has a 16X2 LCD interfaced to Arduino Mega for providing an interface to feed time-table by the user and has a keypad to input related information. Additionally, it an RTC interfaced with the Arduino board to fetch date and time information and a buzzer to ring the school bell. These components and modules are connected to the Arduino board in the following manner –
Power Supply – The project device is line powered. The AC mains is stepped down by a 18V 2A transformer and rectified by a full-bridge rectifier. The rectified AC signal is regulated to 5V and 12V DC by 7805 and 7812 voltage regulator ICs respectively. The pin 1 of both the voltage regulator ICs will be connected to the anode of the battery and pin 2 of both ICs will be connected to ground. The respective voltage outputs will be drawn from pin 3 of the respective voltage regulator ICs.
16X2 LCD: The 16X2 LCD display is used to display the messages prompting to input time-table information. It is connected to the Arduino board by connecting its data pins to pins 3 to 6 of the Arduino board. The RS and E pins of the LCD are connected to pins 13 and 12 of the Arduino Mega respectively. The RW pin of the LCD is grounded.
Fig. 3: Table listing circuit connections between Arduino Uno and Character LCD
The standard open-source library for interfacing LCD with Arduino UNO is used in the project. The library works as expected and needs no changes or modifications.
Buzzer – The buzzer is connected to the pin 24 of the Arduino board. It is connected via a BC547 switching transistor. The base of the transistor is connected to the pin through a 1K ohms pull-up resistor and buzzer is connected at the collector of the transistor. The emitter pin of the transistor is connected to ground. An LED with a pull-up resistor is also connected in parallel to the transistor circuit for visual hint of ringing the school bell.
RTC DC1307 – 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 20) and SCL (Pin 21) pins of the Arduino board.
4-switch Keypad – The keypad is a set of four push-to-on switches which are connected to A0, A1, A2 and A3 pins of the Arduino Mega through 1K ohm pull-up resistors. The switches connected at A0, A1, A2 and A3 pins works as Up/Left, Right, Exit after Saving and Save buttons respectively.
How the circuit works –
Fig. 4: Image of Arduino based Automatic School Bell System
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 24 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.
Programming Guide –
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.
Fig. 5: Screenshot of Initialization in Arduino Code for Automatic School Bell
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.
Fig. 6: Screenshot of Setup Function in Arduino Code for Automatic School Bell
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.
Fig. 7: Screenshot of Arduino Code setting time-table for Automatic School Bell
This completes the Arduino sketch for the Automatic School Bell System.
Project Source Code
###
//Program to #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=A4;//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); pinMode(b2, INPUT); pinMode(b3, INPUT); pinMode(b4, INPUT); pinMode( buzzer, OUTPUT ); digitalWrite( buzzer, LOW ); lcd.begin(16,2); lcd.setCursor(0,0); lcd.print("Engineers Garage"); lcd.setCursor(0,1); lcd.print(" TIME TABLE "); 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; } } /*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(" "); delay(3000); 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 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); } } //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); }
###
Circuit Diagrams
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.