You are on page 1of 10

/*

Date Started: December 28, 2019 #include <Wire.h>

Date Finished: March 24, 2019 #include <DS3231.h>

Team Members: #include <LiquidCrystal_I2C.h>

Aquino, Paul Aries D. #include <OnewireKeypad.h>

Bilhera,Carl Paul D. #include <EEPROM.h>

Ico, Alvin Farnk S.

Ico, Keith Nigel M. //Map the key pressed on keypad module:

Tomas, Brian H. char KEYS[] = {

Facun, Erika Mae M. '1', '2', '3', 'A',

Haluag, Jessica Maureen V. '4', '5', '6', 'B',

Ramirez, Lira Ann Z. '7', '8', '9', 'C',

Visperaz, Alyana Marie T. '*', '0', '#', 'D'

Team Promoter: };

Engr. Paul C. Ang

Project Title: " Dual-Purpose Microcontroller Based School Oriented Alarm // Keypad settings

Arduino Pin Assignment: OnewireKeypad <Print, 16 > KP2(Serial, KEYS, 4, 4, A7, 4700, 1000, 10000);

Digital Pins: // Set the LCD address to 0x3F for a 20 chars and 4 line display

:PIN 0 = rx LiquidCrystal_I2C lcd(0x3F, 20, 4);

:PIN 1 = tx // Initializing the DS3231 using the hardware interface SDA - A4 : SCL - A5

:PIN 2 = Module Push Button (MPB) DS3231 rtc(SDA, SCL);

:PIN 3 = Emergency LED Indicator (ELED)

:PIN 4 = Smoke LED Indicator (SMOKE) Time t; // variable used in addition to DS3231 call function

:PIN 5 = Push Button LED Indicator (PB) int H; // variable use to track the state of time (AM or PM)

:PIN 6 = Alarm Bell Positive Terminal (ALARMp) (Relay 1)

:PIN 7 = Alarm Bell Negative Terminal (ALARMn) (Relay 2) // Digital Pin Assignment

:PIN 8 = Annunciator (SIGN) (Relay 3) int MPB = 2 ; // Module Pushbutton Digital Pin Assignment

:PIN 9 = Reserved Pin (Relay 4) int ELED = 3 ; // Emergency Led Digital Pin Assignment

:PIN 10 = Reserved Pin (Relay 5) int SMOKE = 4 ; // Smoke Sensor Led Indicator Digital Pin Assignment

:PIN 11 = Reserved Pin (Relay 6) int PB = 5 ; // Pushbutton Led Indicator Digital Pin Assignment

:PIN 12 = Smoke Sensor Terminating Switch (Relay 7) int ALARMp = 6 ; // Alarm Bell Digital Pin Output Asssignment (Positive)

:PIN 13 = Reserved Pin (Relay 8) int ALARMn = 7 ; // Alarm Bell Digital Pin Output Asssignment (Ground)

Analog Pins: int SIGN = 8 ; // Annunciator Digital Pin Output Assignment

:ANALOG 0 = Smoke Sensor int SSS = 12 ; // Smoke Sensor Switch Pin Output Assignment

:ANALOG 1 = Smoke Sensor Pilot LED

:ANALOG 2 = Emergency Terminator Push Button // Analog Pin Assignment

:ANALOG 3 = Reserved Analog Pin int Sensor = A0 ; // Analog Pin Assignment of Smoke Sensor

:ANALOG 4 = SDA int PLed = A1 ; // Analog Pin Assignment of Smoke Sensor Pilot Led

:ANALOG 5 = SCL int ETPB = A2 ; // Analog Pin Assignment of Emergency Terminating Push Button

:ANALOG 6 = Emergency Push Buttons int EPB = A6 ; // Analog Pin Assignment of Emergency Push Button

:ANALOG 7 = 4X4 Keypad Matrix Analog Output

*/
// EEPROM Storage Address pinMode (ALARMn,OUTPUT); // declare that the pin is an OUTPUT

int aBD = 0; // address of Bell Duration Value pinMode (SIGN,OUTPUT); // declare that the pin is an INPUT

int aBI = 1; // address of Bell Interval Value pinMode (SSS,OUTPUT); // declare that the pin is an OUTPUT

int aAD = 2; // address of Alarm Duration Value

int aAI = 3; // address of Alarm Interval Value

int aMWF = 4; // address of MWF Interval Value // Relay Initialization High for OFF Low For ON

int aTTHS = 5; // address of TTHS Interval Value digitalWrite(ALARMp,HIGH); // Positive Supply of Bell

digitalWrite(ALARMn,HIGH); // Negative Supply of Bell

// LOOP Destination digitalWrite(SIGN,HIGH); // Annunciator Triger Relay Switch

char NORMAL; // NORMAL OR DEFAULT INSTRUCTION DESTINATION digitalWrite(SSS,HIGH); // Smoke Sensor Relay Switch Terminator

char SETTINGS; // SETTINGS INSTRUCTION DESTINATION

char SYSTEM; // SYSTEM INSTRUCTION DESTINATION

char EMERGENCY; // EMERGENCY INSTRUCTION DESTINATION


KP2.SetKeypadVoltage(5.01); // keypad supply voltage reading
char DMY; // DATE SETTINGS
KP2.SetHoldTime(1); // Set hold time for keypad to tell if key is on Hold
char HMS; // TIME SETTINGS

char ASET; // EMERGENCY ALARM SETTINGS

char BSET; // BELL TIME SETTINGS lcd.begin(); // initialize the LCD

char LOOP; // LOOP lcd.backlight(); // Turn on the blacklight and print a message.

char DRING; // DOUBLE RINGING ACTION rtc.begin(); // Initialize the rtc object

char SRING; // SINGLE RINGING ACTION

// The following lines can be uncommented to set the date and time
char OHTF; // ONE HOUR TIME FORMAT
//rtc.setDOW(SATURDAY); // Set Day-of-Week
char OHHTF; // ONE AND HALF TIME FORMAT
//rtc.setTime(10, 58, 10); // Set the time (Hour-Minute-Sec)
char SCHED; // SCHEDULE SETTINGS
//rtc.setDate(28, 12, 2019); // Set the date (Date-Month-Year)
char LSCHED; // SCHED LOOP RETURN

// The following lines can be uncommented to set the Default Bell and Alarm Settings
// Emergency Settings
//EEPROM.write(aBD,3); // Bell Duration (During Normal Operation)
char Aloop; // For LOOP SETTINGS
//EEPROM.write(aBI,2); // Bell Interval (During Normal Operation)
char Enote; // Destination After Emergency Alert
//EEPROM.write(aAD,3); // Alarm Duration (During Emergency Operation)

//EEPROM.write(aAI,2); // Alarm Interval (During Emergency Operation)


// Date and Time Loop
//EEPROM.write(aMWF,1); // MWF Time Format / Interval 1= One Hour Format 2=
char Dloop; // Date Setting Conditional Loop Destination One and One Half Hour Format

char Tloop; // Time Setting Conditional Loop Destination //EEPROM.write(aTTHS,2); // TTHS Time Format / Interval 1= One Hour Format 2=
One and One Half Hour Format

void setup()
// Introduction Only:
{
lcd.setCursor(0,0);
// Arduino Pin Mode declaration
lcd.print(" DUAL-PURPOSE");
pinMode (MPB,INPUT); // declare that the pin is an INPUT
lcd.setCursor(0,1);
pinMode (ELED,OUTPUT); // declare that the pin is an OUTPUT
lcd.print(" ALARM SYSTEM");
pinMode (SMOKE,OUTPUT); // declare that the pin is an OUTPUT
delay(5000);
pinMode (PB,OUTPUT); // declare that the pin is an INPUT
lcd.clear();
pinMode (ALARMp,OUTPUT); // declare that the pin is an OUTPUT
H=t.hour-12;} // If True Hour to Display is equal to RTC Hour minus 12

else { lcd.setCursor(14,1); // If False set cursor to Row 1 Column 14


}
H=t.hour; // If False Hour to Display is equal to RTC Hour
void loop(){
lcd.print(" AM");}; // If True print PM on LCD

// Declaring Characters as long intiger used to temporarily store long numeric values
// Dispaly Time
long Day, Month, Year, Min, Hour, Sec, eAD, eAI, eBD, eBI, eMWF, eTTHS, DOW ;
lcd.setCursor(0,0);

lcd.print("-------H--M--S------");
//
======================================================================== lcd.setCursor(0,1);
======================:
lcd.print("Time: ");
NORMAL: // Default Program Loop Destination that always display time and date :
lcd.print(H);
// Check the Status of Time and Emergency Devices (Smoke Sensor & Emergency
Switches): lcd.print(":");

lcd.print(t.min, DEC);

lcd.print(":");
// CONDITION FOR USER INTERFACE
lcd.print(t.sec, DEC);
if(KP2.Getkey()=='*'){lcd.clear(); goto SETTINGS;} // If True: Direct the Program to
Settings
lcd.print(" ");
if(KP2.Getkey()=='B'){lcd.clear(); goto SYSTEM;} // If True: Direct the Program to
System
// Display Date

lcd.setCursor(0,2);
// CONDITION FOR EMERGENCY SETTINGS
lcd.print("Date: ");
if(digitalRead(MPB)==HIGH){lcd.clear(); goto EMERGENCY;} // Check Module Push
Button State lcd.print(rtc.getDateStr());

if(analogRead(Sensor)>500){lcd.clear(); goto EMERGENCY;} // Check Smoke Sensor lcd.setCursor(0,3);


State
lcd.print("-------D--M--Y------");
if(analogRead(EPB)>500){lcd.clear(); goto EMERGENCY;} // Check Input Emergency
Switches State
// ALARM CHECKING INSTRUCTION

if (t.dow == 7){goto NORMAL;} // If Day of the week is equal to 7 (Sunday) go to


// Get data from the DS3231 Normal operation

t = rtc.getTime(); // Allows the following program to use RTC functions

// MWF STATUS CHECKER

if (t.dow==1||t.dow==3||t.dow==5){ // If Day of the week is equal to 1, 3, and 5


// Set and Display Day of the Week:
(Monday, Wenesday, and Friday Respectively) Execute the following
if(t.dow==1){lcd.setCursor(17,2);lcd.print("M");}
if (EEPROM.read(aMWF)==1){goto OHTF;} // Read MWF Format on EEPROM if 1
execute One Hour Time Format
if(t.dow==2){lcd.setCursor(17,2);lcd.print("T");}
goto OHHTF; // If 2 execute One and One Half Hour Format
if(t.dow==3){lcd.setCursor(17,2);lcd.print("W");}
}
if(t.dow==4){lcd.setCursor(17,2);lcd.print("Th");}
// TTHS STATUS CHECKER
if(t.dow==5){lcd.setCursor(17,2);lcd.print("F");}
if (t.dow==2||t.dow==4||t.dow==6){
if(t.dow==6){lcd.setCursor(17,2);lcd.print("Sat");}
if (EEPROM.read(aTTHS)==1){goto OHTF;}
if(t.dow==7){lcd.setCursor(17,2);lcd.print("Sun");}
goto OHHTF;

}
// Condition Program for AM and PM

if (t.hour >12){ // Check the RTC if Hour are greater than 12


lcd.clear();
lcd.setCursor(14,1); // If True set cursor to Row 1 Column 14
goto NORMAL; // Repeat the Program Under the Normal Destination
lcd.print(" PM"); // If True print PM on LCD
SRING: // Execute the Code to Ring the Bell Once

//
========================================================================
======================: digitalWrite(ALARMp, LOW);

OHTF: // Checks The Alarm Time With OHTF (One Hour Time Format) digitalWrite(ALARMn, LOW);

delay(EEPROM.read(aBD)*1000);

t = rtc.getTime(); digitalWrite(ALARMp, HIGH);

if((t.hour>=7)&&(t.hour<21)&&(t.min==25)&&(t.sec==0)){goto SRING;} digitalWrite(ALARMn, HIGH);

if((t.hour>=7)&&(t.hour<21)&&(t.min==30)&&(t.sec==0)){goto DRING;} lcd.clear();

goto NORMAL; goto NORMAL;

// //
======================================================================== ========================================================================
======================: ======================:

OHHTF:// Checks The Alarm Time With OHHTF (One Hour and Half Time Format) EMERGENCY:

// Display Indication of Trigered Emergency Input Devices

t = rtc.getTime();

if ((t.hour==7||t.hour==10||t.hour==13||t.hour==16|| if(analogRead(Sensor)>500){
t.hour==19)&&(t.min==25&&t.sec==0)){goto SRING;}
digitalWrite(SMOKE,HIGH);
if ((t.hour==7||t.hour==10||t.hour==13||t.hour==16||
t.hour==19)&&(t.min==30&&t.sec==0)){goto DRING;} } // For Smoke Sensor

if ((t.hour==8||t.hour==11||t.hour==13||t.hour==14||
t.hour==17)&&(t.min==55&&t.sec==0)){goto SRING;}
if(analogRead(EPB)<500){
if ((t.hour==9||t.hour==12||t.hour==15||t.hour==18)&&(t.min==0&&t.sec==0)){goto
DRING;} digitalWrite(PB,HIGH);

goto NORMAL; } // For Emergency Push Buttons

//
======================================================================== lcd.clear();
======================:
lcd.setCursor(0,0);
DRING: // Execute the Code to Ring the Bell Twice
lcd.print(" WARNING WARNING ");

lcd.setCursor(0,1);
digitalWrite(ALARMp, LOW);
lcd.print(" EMERGENCY ALERT ");
digitalWrite(ALARMn, LOW);
lcd.setCursor(0,2);
delay(EEPROM.read(aBD)*1000);
lcd.print("*------------------*");
digitalWrite(ALARMn, HIGH);
lcd.setCursor(0,3);
delay(EEPROM.read(aBI)*1000);
lcd.print("LONG PRESS (E)- EXIT");
digitalWrite(ALARMn, LOW);
digitalWrite(SIGN,LOW);
delay(3000);
delay(100);
digitalWrite(ALARMp, HIGH);

digitalWrite(ALARMn, HIGH);

lcd.clear();
while(analogRead(ETPB)<500){
goto NORMAL;
digitalWrite(ELED,HIGH);

digitalWrite(ALARMp,LOW);
//
======================================================================== digitalWrite(ALARMn,LOW);
======================:
delay(EEPROM.read(aAD)*1000);
digitalWrite(ELED,LOW); lcd.setCursor(0,0);

digitalWrite(ALARMn,HIGH); lcd.print("SYSTEM ==> SET(*)");

delay(EEPROM.read(aAI)*1000);

} lcd.setCursor(0,1);

delay(2000); lcd.print("BD: ");

lcd.clear(); lcd.print(EEPROM.read(aBD));

goto Enote; lcd.setCursor(7,1);

lcd.print("AD: ");

// lcd.print(EEPROM.read(aAD));
========================================================================
======================: lcd.setCursor(14,1);

Enote: // Display Emergency Note Displaying Triggered Input Devices Leds lcd.print("MWF: ");

lcd.print(EEPROM.read(aMWF));

digitalWrite(ALARMp,HIGH);

digitalWrite(ALARMn,HIGH); lcd.setCursor(0,2);

digitalWrite(ELED,HIGH); lcd.print("BI: ");

digitalWrite(SSS,LOW); lcd.print(EEPROM.read(aBI));

digitalWrite(SIGN,LOW); lcd.setCursor(7,2);

lcd.print("AI: ");

lcd.clear(); lcd.print(EEPROM.read(aAI));

lcd.setCursor(0,0); lcd.setCursor(14,2);

lcd.print("AN EMERGENCY DEVICE"); lcd.print("TTS: ");

lcd.setCursor(0,1); lcd.print(EEPROM.read(aTTHS));

lcd.print("WERE TRIGGERED");

lcd.setCursor(0,2); lcd.setCursor(0,3);

lcd.print("--------------------"); lcd.print("EXT(C)");

lcd.setCursor(0,3); lcd.setCursor(14,3);

lcd.print("Back To Normal : 'C'"); lcd.print("DOW: ");

lcd.print(t.dow);

while(KP2.Getkey()!='C'){}

digitalWrite(SMOKE,LOW); while(KP2.Getkey()==NO_KEY){}

digitalWrite(PB,LOW); if (KP2.Getkey()=='C'){delay(500); lcd.clear(); goto NORMAL;}

digitalWrite(ELED,LOW); if (KP2.Getkey()=='*'){delay(500); lcd.clear(); goto SETTINGS;}

digitalWrite(SIGN,HIGH);

digitalWrite(SSS,HIGH);
goto SYSTEM;
lcd.clear();

goto NORMAL;
//
========================================================================
======================:
//
SETTINGS: // Display Settings Window On What To Edit
========================================================================
======================:

SYSTEM: // Display SYSTEM SETED Configuration


lcd.setCursor(0,0);

lcd.print(" MODULE SETTINGS <>");


lcd.clear();
lcd.setCursor(0,1); lcd.setCursor(0,3);

lcd.print("DATE = 1"); lcd.print("Range (1-12) : (B)->");

lcd.setCursor(0,2); lcd.setCursor(0,1);

lcd.print("TIME = 2"); lcd.print("SET MONTH: ");

lcd.setCursor(0,3); lcd.setCursor(11,1);

lcd.print("BELL = 3"); Month = GetNumber();

lcd.setCursor(11,1);

lcd.print("ALARM = 4");
lcd.clear();
lcd.setCursor(11,2);
lcd.setCursor(0,3);
lcd.print("M.TH. = 5");
lcd.print("Range (2019+): (B)->");
lcd.setCursor(11,3);
lcd.setCursor(0,1);
lcd.print("EXT(C)");
lcd.print("SET YEAR: ");

lcd.setCursor(10,1);
if(KP2.Getkey()=='1'){lcd.clear();goto DMY;}
Year = GetNumber();
if(KP2.Getkey()=='2'){lcd.clear();goto HMS;}

if(KP2.Getkey()=='3'){lcd.clear();goto BSET;}
lcd.clear();
if(KP2.Getkey()=='4'){lcd.clear();goto ASET;}
lcd.setCursor(0,3);
if(KP2.Getkey()=='5'){lcd.clear();goto SCHED;}
lcd.print("Range (1-7) : (B)->");
if(KP2.Getkey()=='C'){lcd.clear();goto NORMAL;}
lcd.setCursor(0,1);
while(KP2.Getkey()==NO_KEY){}
lcd.print("SET DOW: ");
goto SETTINGS;
lcd.setCursor(9,1);

DOW = GetNumber();
//
========================================================================
======================:

DMY: // Program Instruction To Modify The Date, Month, Year, and DOW (Day Of the Dloop:
Week)
lcd.clear();

lcd.setCursor(0,0);
lcd.setCursor(0,1);
lcd.print("Is Date Correct ?:");
lcd.print(" DAY MONTH YEAR");
lcd.setCursor(0,1);
delay(1000);
lcd.print(Day);
t = rtc.getTime();
lcd.print(":");

lcd.print(Month);
lcd.clear();
lcd.print(":");
lcd.setCursor(0,3);
lcd.print(Year);
lcd.print("Range (1-31) : (B)->");
lcd.setCursor(0,2);
lcd.setCursor(0,1);
lcd.print("DOW: ");
lcd.print("SET DAY: ");
lcd.print(DOW);
lcd.setCursor(9,1);
lcd.setCursor(0,3);
Day = GetNumber();
lcd.print("YES=1 NO=2 EXIT='C'");

while(KP2.Getkey()==NO_KEY){}

if(KP2.Getkey()=='1'){
lcd.clear();
rtc.setDate(Day, Month, Year); Tloop:

rtc.setDOW(DOW); lcd.clear();

delay(500); goto SETTINGS;} lcd.setCursor(0,0);

if(KP2.Getkey()=='2'){lcd.clear(); goto DMY;} // Repeat The DMY Instruction lcd.print("Is TIME Correct ?");

if(KP2.Getkey()=='C'){lcd.clear(); goto NORMAL;} // Cancel The Program. Returns to lcd.setCursor(0,1);


Normal
lcd.print("TIME: ");
goto Dloop; // Ignores Wrong Keypad Input
lcd.print(Hour);

lcd.print(":");
//
======================================================================== lcd.print(Min);
======================:
lcd.print(":");
HMS: // Program Instruction To Modify The Hour, Minute,and Second
lcd.print(Sec);

lcd.setCursor(0,3);
lcd.setCursor(0,0);
lcd.print("YES=1 NO=2 EXIT='C'");
lcd.print(" HOUR-MIN-SEC");
while(KP2.Getkey()==NO_KEY){}
delay(1000);

t = rtc.getTime();
if(KP2.Getkey()=='1'){
delay(1000);
t = rtc.getTime();

rtc.setTime(Hour, Min, Sec);


lcd.clear();
delay(500); goto SETTINGS;}
lcd.setCursor(0,3);
if(KP2.Getkey()=='2'){lcd.clear(); goto HMS;} // Repeat the HMS Program
lcd.print("Range (1-24) : (B)->");
if(KP2.Getkey()=='C'){lcd.clear(); goto NORMAL;} // Cancel The Program. Returns to
lcd.setCursor(0,1); Normal

lcd.print("SET HOUR: "); goto Tloop; // Ignores Wrong Keypad Input

lcd.setCursor(10,1);

Hour = GetNumber(); //
========================================================================
======================:

ASET: // EMERGENCY ALARM SETTINGS: ALARM DURATION AND ALARM INTERVAL


lcd.clear();
lcd.setCursor(0,2);
lcd.setCursor(0,3);
lcd.print("ALARM SETTINGS");
lcd.print("Range (0-59) : (B)->");
delay(1000);
lcd.setCursor(0,1);

lcd.print("SET MIN: ");


lcd.clear();
lcd.setCursor(9,1);
lcd.setCursor(0,3);
Min = GetNumber();
lcd.print("Range(0-5 sec):(B)->");

lcd.setCursor(0,1);
lcd.clear();
lcd.print("ALARM DURATION: ");
lcd.setCursor(0,3);
lcd.setCursor(16,1);
lcd.print("Range (0-59) : (B)->");
eAD = GetNumber();
lcd.setCursor(0,1);

lcd.print("SET SEC: ");


lcd.clear();
lcd.setCursor(9,1);
lcd.setCursor(0,3);
Sec = GetNumber();
lcd.print("Range(0-5 sec):(B)->");
lcd.setCursor(0,1); lcd.setCursor(15,1);

lcd.print("ALARM INTERVAL: "); eBD = GetNumber();

lcd.setCursor(16,1);

eAI = GetNumber();
lcd.clear();

lcd.setCursor(0,3);

Aloop: lcd.print("Range(0-5 sec):(B)->");

lcd.clear(); lcd.setCursor(0,1);

lcd.setCursor(0,0); lcd.print("BELL INTERVAL: ");

lcd.print("INPUT CORRECT ?"); lcd.setCursor(15,1);

lcd.setCursor(0,1); eBI = GetNumber();

lcd.print("AD=");

lcd.print(eAD);
LOOP:
lcd.setCursor(11,1);
lcd.clear();
lcd.print("AI=");
lcd.setCursor(0,0);
lcd.print(eAI);
lcd.print("INPUT CORRECT ?");
lcd.setCursor(0,3);
lcd.setCursor(0,1);
lcd.print("YES=1 NO=2 EXIT='C'");
lcd.print("BD=");
while(KP2.Getkey()==NO_KEY){}
lcd.print(eBD);

lcd.setCursor(11,1);
if(KP2.Getkey()=='1'){
lcd.print("BI=");
EEPROM.write(aAD,eAD);
lcd.print(eBI);
EEPROM.write(aAI,eAI);
lcd.setCursor(0,3);
delay(500); goto SETTINGS; }
lcd.print("YES=1 NO=2 EXIT='C'");
if(KP2.Getkey()=='2'){lcd.clear(); goto ASET;} // Repeat the Alarm Settings
while(KP2.Getkey()==NO_KEY){}
Program

if(KP2.Getkey()=='C'){lcd.clear(); goto NORMAL;} // Cancel The Program. Returns to


Normal
if(KP2.Getkey()=='1'){
goto Aloop; // Ignores Wrong Keypad Input
EEPROM.write(aBD,eBD);

EEPROM.write(aBI,eBI);
//
======================================================================== delay(500); goto SETTINGS; }
======================:
if(KP2.Getkey()=='2'){lcd.clear(); goto BSET;} // Repeat the Bell Settings Program
BSET: // TIME SETTINGS:
if(KP2.Getkey()=='C'){lcd.clear(); goto NORMAL;} // Cancel The Program. Returns to
Normal

lcd.setCursor(0,0); goto LOOP; // Ignores Wrong Keypad Input

lcd.print("BELL SETTINGS");

delay(1000); //
========================================================================
======================:

lcd.clear(); SCHED: // SCHEDULE FORMAT:

lcd.setCursor(0,3);

lcd.print("Range(0-5 sec):(B)->"); lcd.setCursor(0,0);

lcd.setCursor(0,1); lcd.print("MWF & TTHS SETTINGS:");

lcd.print("BELL DURATION: "); delay(2000);


EEPROM.write(aMWF,eMWF);

lcd.clear(); EEPROM.write(aTTHS,eTTHS);

lcd.setCursor(15,0); delay(500);goto SETTINGS; }

lcd.print("(B)->"); if(KP2.Getkey()=='2'){lcd.clear(); goto SCHED;} // Repeat the Schedule Program

lcd.setCursor(0,2); if(KP2.Getkey()=='C'){lcd.clear(); goto NORMAL;} // Cancel The Program. Returns


to Normal
lcd.print("1=(1 Hour F.)");
goto LSCHED; // Ignores Wrong Keypad Input
lcd.setCursor(0,3);
}
lcd.print("2=(1.5 Hour F.)");

lcd.setCursor(0,1);
//
lcd.print("SET MWF FORMAT: "); ========================================================================
======================:
lcd.setCursor(16,1);
// Call Function Used For Long Number Keypad Reading
eMWF = GetNumber();
int GetNumber()

{
lcd.clear();
long num = 0;
lcd.setCursor(15,0);
char key = KP2.Getkey();
lcd.print("(B)->");
while(key != 'B')
lcd.setCursor(0,2);
{
lcd.print("1=(1 Hour F.)");
switch (key)
lcd.setCursor(0,3);
{
lcd.print("2=(1.5 Hour F.)");
case NO_KEY:
lcd.setCursor(0,1);
break;
lcd.print("SET TThS FORMAT: ");

lcd.setCursor(16,1);
case '0': case '1': case '2': case '3': case '4':
eTTHS = GetNumber();
case '5': case '6': case '7': case '8': case '9':

LSCHED:
delay(200);
lcd.clear();
lcd.print(key);
lcd.setCursor(0,0);

lcd.print("INPUT CORRECT ?");


num = num * 10 + (key -'0');
lcd.setCursor(0,1);
break;
lcd.print("MWF= ");

lcd.print(eMWF);

lcd.setCursor(11,1); case 'A': case '*': case 'D': case 'C':

lcd.print("TThS= "); num = 0;

lcd.print(eTTHS); lcd.clear();

lcd.setCursor(0,3); lcd.setCursor(0,1);

lcd.print("YES=1 NO=2 EXIT='C'"); lcd.print("Press: 'B'");

lcd.setCursor(0,2);

lcd.print("WRONG INPUT: ");


while(KP2.Getkey()==NO_KEY){}
break;

}
if(KP2.Getkey()=='1'){
key = KP2.Getkey();

delay(200);

return num;

You might also like