Hai My dear friends....
I need your help as fast as possible. I am a Beginner and trying to make one college alarm as our project. I made one code for that but that is not working properly
I cut short my code due to overflow.
please give me an idea, how to make bell on different times
#include <DS3231.h>
#include <Wire.h>
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;
int buzzer=13;
int exam;
int exampm;
byte year, month, date, DoW, hour, minute, second;
void setup() {
// Start the I2C interface
Wire.begin();
/*Clock.setSecond(50);//Set the second
Clock.setMinute(50);//Set the minute
Clock.setHour(20); //Set the hour
Clock.setDoW(2); //Set the day of the week
Clock.setDate(27); //Set the date of the month
Clock.setMonth(2); //Set the month of the year
Clock.setYear(17); //Set the year (Last two digits of the year)*/
int buzzer =13;
pinMode(buzzer,OUTPUT);
// Start the serial interface
Serial.begin(115200);
}
void ReadDS3231()
{
int second,minute,hour,date,month,year,temperature,dow;
second=Clock.getSecond();
minute=Clock.getMinute();
hour=Clock.getHour(h12, PM);
date=Clock.getDate();
month=Clock.getMonth(Century);
year=Clock.getYear();
dow=Clock.getDoW();
temperature=Clock.getTemperature();
Serial.println("20");
Serial.print(year,DEC);
Serial.print('-');
Serial.print(month,DEC);
Serial.print('-');
Serial.print(date,DEC);
Serial.println();
Serial.print(hour,DEC);
Serial.print(':');
Serial.print(minute,DEC);
Serial.print(':');
Serial.print(second,DEC);
Serial.print('\n');
Serial.print("Temperature=");
Serial.print(temperature);
Serial.print('\n');
Serial.print(dow);
Serial.print('\n');
}
// ######################################################
void normalbell (){
digitalWrite(buzzer,HIGH);
delay(5000);
digitalWrite(buzzer,LOW);
}
void exambell (){
digitalWrite(buzzer,HIGH);
delay(7000);
digitalWrite(buzzer,LOW);
}
void normal_week(){
int x=Clock.getHour(h12, PM);
int y=Clock.getMinute();
int z=Clock.getSecond();
// ---start---------------------
if(x==8 && y==20 && z==5) {
normalbell();
}
Serial.println("FIRST BELL");
//--------------------------------
if(x==8 && y==30 && z==5) {
normalbell();
}
Serial.println("FIRST PERIOD");
//----------------------------
//### EXAM $$$$$$$$$$$$$$$$
if (exam=1){
if(x==9 && y==20 && z==5) {
exambell();
}
Serial.println("EXAM BELL");
delay(15000);
Serial.println("FIRST PERIOD");
}
//$$$$$$$$ Exam $$$$$$$$$
if (exampm=1){
if(x==13 && y==20 && z==3) {
exambell();
}
Serial.println("EXAM BELL");
delay(15000);
Serial.println("LUNCH TIME");
}
//$$$$$$$$$$$$$$$$$$$
if(x==13 && y==30 && z==5) {
exambell();
}
Serial.println("FIFTH HOUR");
//---------------------------
}
// FRIDAY TIMETABLE ######################################
void friday_week(){
int x=Clock.getHour(h12, PM);
int y=Clock.getMinute();
int z=Clock.getSecond();
// ---start---------------------
if(x==8 && y==20 && z==5) {
normalbell();
}
Serial.println("FIRST BELL");
//--------------------------------
if(x==8 && y==30 && z==5) {
normalbell();
}
Serial.println("FIRST PERIOD");
//----------------------------
//$$$$$$$$ Exam $$$$$$$$$
if (exam=1){
if(x==9 && y==20 && z==3) {
exambell();
}
Serial.println("EXAM BELL");
delay(15000);
Serial.println("FIRST PERIOD");
}
//$$$$$$$$$$$$$$$$$$$
if(x==9 && y==30 && z==5) {
exambell();
}
Serial.println("SECOND PERIOD");
//----------------------------
//$$$$$$$$ Exam $$$$$$$$$
if (exam=1){
if(x==10 && y==0 && z==3) {
exambell();
}
Serial.println("EXAM BELL");
delay(15000);
Serial.println("SECOND PERIOD");
}
//$$$$$$$$$$$$$$$$$$$
if(x==12 && y==30 && z==5) {
exambell();
}
Serial.println("LUNCH TIME");
//----------------------------
//$$$$$$$$ Exam $$$$$$$$$
if (exampm=1){
if(x==13 && y==50 && z==3) {
exambell();
}
Serial.println("EXAM BELL");
delay(15000);
Serial.println("EXAM BELL");
}
//$$$$$$$$ Exam $$$$$$$$$
if (exampm=1){
if(x==16 && y==0 && z==3) {
exambell();
}
Serial.println("EXAM BELL");
delay(15000);
Serial.println("SEVENTH PERIOD");
}
//$$$$$$$$$$$$$$$$$$$
if (x==16 && y==30 && z==5) {
normalbell();
}
Serial.println("LAST BELL");
//---------------------------;
//$$$$$$$$ Exam $$$$$$$$$;
if (exampm=1){
if(x==16 && y==45 && z==3) {
exambell();
}
Serial.println("EXAM BELL");
}
//$$$$$$$$$$$$$$$$$$$;
//$$$$$$$$ Exam $$$$$$$$$;
if(exampm=1){
if(x==17 && y==0 && z==3) {
exambell();
}
Serial.println("EXAM BELL");
delay(15000);
Serial.println("GOOD BYE");
}
}
//$$$$$$$$$$$$$$$$$$$
//##################################################
I hope you can help me..... my friends pls