guys please check the code & help me for my project
this project is suppose to be a health reminder. it should take input of when u wakeup & when u sleep & also input of the time of any medicines that u take and also the date and time of ur monthy doc checkup. and then gives reminder accordingly to take medicines, drink water, go to doctor, take a morning/evening walk.
I'm using the following stuff: do i need anything else?
Arduino Uno,16X2 Liquid Crystal Display, DS1307,Buzzer,Push buttons
#include <Wire.h>
#include<EEPROM.h>
#include <RTClib.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
RTC_DS1307 RTC;
int temp,hours1,minut,add=0,d,m;
int next=10;
int INC=9;
int set=8;
#define buzzer 13
int HOUR,MINUT,SECOND,dd,mm,yy;
void setup()
{
Wire.begin();
RTC.begin();
lcd.begin(16,2);
pinMode(INC, INPUT);
pinMode(next, INPUT);
pinMode(set, INPUT);
pinMode(buzzer, OUTPUT);
lcd.setCursor(0,0);
lcd.print("Health Assistant");
lcd.setCursor(0,1);
lcd.print("By MEDICODERS");
delay(2000);
if(!RTC.isrunning())
{
RTC.adjust(DateTime(__DATE__,__TIME__));
}
}
void loop()
{
DateTime now = RTC.now();
if(digitalRead(set) == 0) //set or reset
{
sleep(); //to get sleep time
doc(); //to get monthly doc checkup
meds(); //to get medicine reminder time
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Time:");
lcd.setCursor(6,0);
lcd.print(HOUR=now.hour(),DEC);
lcd.print(":");
lcd.print(MINUT=now.minute(),DEC);
lcd.print(":");
lcd.print(SECOND=now.second(),DEC);
lcd.setCursor(0,1);
lcd.print("Date: ");
lcd.print(dd=now.day(),DEC);
lcd.print("/");
lcd.print(mm=now.month(),DEC);
lcd.print("/");
lcd.print(yy=now.year(),DEC);
match();
delay(200);
}
void defualt()
{
lcd.setCursor(0,1);
lcd.print(HOUR);
lcd.print(":");
lcd.print(MINUT);
lcd.print(":");
lcd.print(SECOND);
}
void time1() // Function to set alarm time and feed time into Internal eeprom
{
int temp=1;
while(temp==1)
{
if(digitalRead(INC)==0)
{
HOUR++;
if(HOUR==24)
{
HOUR=0;
}
while(digitalRead(INC)==0);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Enter Time ");
lcd.setCursor(0,1);
lcd.print(HOUR);
lcd.print(":");
lcd.print(MINUT);
lcd.print(":");
lcd.print(SECOND);
delay(100);
if(digitalRead(next)==0)
{
hours1=HOUR;
EEPROM.write(add++,hours1);
temp=2;
while(digitalRead(next)==0);
}
}
while(temp==2)
{
if(digitalRead(INC)==0)
{
MINUT++;
if(MINUT==60)
{MINUT=0;}
while(digitalRead(INC)==0);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Enter Time ");
lcd.setCursor(0,1);
lcd.print(HOUR);
lcd.print(":");
lcd.print(MINUT);
lcd.print(":");
lcd.print(SECOND);
delay(100);
if(digitalRead(next)==0)
{
minut=MINUT;
EEPROM.write(add++, minut);
temp=0;
while(digitalRead(next)==0);
}
}
delay(1000);
}
void match() //Function to check match date/time
{
int tem[19];
for(int i=0;i<18;i++)
{
tem[i]=EEPROM.read(i);
}
if(HOUR == tem[0] && MINUT == tem[1]) //drink water/exercise reminder
{
int mexr=HOUR;
int wtr=HOUR;
buzz();
lcd.setCursor(0,0);
lcd.print("Wake up");
buzz();
while(HOUR != tem[2] && MINUT != tem[3])
{
if(HOUR==wtr) //for water reminder
{
buzz();
lcd.setCursor(0,0);
lcd.print("Take a sip");
buzz();
}
wtr=wtr+2;
if(HOUR==mexr+1) //for morning walk
{
buzz();
lcd.setCursor(0,0);
lcd.print("Morning walk");
buzz();
}
if(HOUR==17 && MINUT==30) //for evening walk
{
buzz();
lcd.setCursor(0,0);
lcd.print("Evening walk");
buzz();
}
if(HOUR == tem[9] && MINUT == tem[10]) //to match medicine group 1
{
buzz();
lcd.setCursor(0,0);
lcd.print(" Take Group 1 ");
lcd.setCursor(0,1);
lcd.print(" Medicine ");
buzz();
}
if(HOUR == tem[11] && MINUT == tem[12]) //to match medicine group 2
{
buzz();
lcd.setCursor(0,0);
lcd.print(" Take Group 2 ");
lcd.setCursor(0,1);
lcd.print(" Medicine ");
buzz();
}
if(HOUR == tem[13] && MINUT == tem[14]) //to match medicine group 3
{
buzz();
lcd.setCursor(0,0);
lcd.print(" Take Group 3 ");
lcd.setCursor(0,1);
lcd.print(" Medicine ");
buzz();
}
if(HOUR == tem[15] && MINUT == tem[16]) //to match medicine group 4
{
buzz();
lcd.setCursor(0,0);
lcd.print(" Take Group 4 ");
lcd.setCursor(0,1);
lcd.print(" Medicine ");
buzz();
}
if(HOUR == tem[17] && MINUT == tem[18]) //to match medicine group 5
{
buzz();
lcd.setCursor(0,0);
lcd.print(" Take Group 5 ");
lcd.setCursor(0,1);
lcd.print(" Medicine ");
buzz();
}
if(dd == tem[5] && mm == tem[6]) //to match monthly doc checkup
{
if(HOUR == tem[7] && MINUT == tem[8])
buzz();
buzz();
lcd.setCursor(0,0);
lcd.print("Time for Monthly");
lcd.setCursor(0,1);
lcd.print("Doctor Checkup");
buzz();
buzz();
}
}
}
if(HOUR == tem[2] && MINUT == tem[3])
{
buzz();
lcd.setCursor(0,0);
lcd.print("Time for sleep");
buzz();
}
}
void buzz() //to repeat beep
{
beep();
beep();
}
void beep() //function for buzzer indication
{
digitalWrite(buzzer,HIGH);
delay(500);
digitalWrite(buzzer, LOW);
delay(500);
}
void meds() //to get medicine reminder time
{
lcd.setCursor(0,0);
lcd.print("Do u take meds?");
lcd.setCursor(0,1);
lcd.print("yes->In no->Next");
delay(2000);
lcd.clear();
if(digitalRead(INC) == 0)
{ int n=1;
if(digitalRead(INC)==0)
{
n++;
while(digitalRead(INC)==0);
}
lcd.setCursor(0,0);
lcd.print("Enter Max 5 timings");
lcd.setCursor(0,1);
lcd.print("How many?(In)");
lcd.print(n);
delay(100);
if(digitalRead(next)==0)
{
EEPROM.write(add++,n);
while(digitalRead(next)==0);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Set Medicine ");
lcd.setCursor(0,1);
lcd.print(" Reminder time ");
delay(2000);
for(int i=1;i<=n;i++)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Enter Time ");
lcd.print(i);
defualt();
time1();
delay(1000);
}
lcd.setCursor(0,0);
lcd.print("Med reminder");
lcd.setCursor(0,1);
lcd.print("time is set");
delay(2000);
}
else if(digitalRead(next) == 0)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Gud to know that");
delay(2000);
}
}
void sleep() //to get sleep time
{
lcd.setCursor(0,0);
lcd.print("U wakeup at");
defualt();
time1();
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("U sleep at");
defualt();
time1();
delay(1000);
}
void doc() //to get monthly doc checkup
{
lcd.setCursor(0,0);
lcd.print("Monthly Doc check");
lcd.setCursor(0,1);
lcd.print("date & time");
date();
time1();
delay(1000);
}
void date() //to get the date
{
int temp=1;
while(temp==1)
{
if(digitalRead(INC)==0)
{
dd++;
while(digitalRead(INC)==0);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Enter Date ");
lcd.setCursor(0,1);
lcd.print(dd);
lcd.print("/");
lcd.print(mm);
lcd.print("/");
lcd.print(yy);
delay(100);
if(digitalRead(next)==0)
{
d=dd;
EEPROM.write(add++,d);
temp=2;
while(digitalRead(next)==0);
}
}
while(temp==2)
{
if(digitalRead(INC)==0)
{
mm++;
while(digitalRead(INC)==0);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Enter Date ");
lcd.setCursor(0,1);
lcd.print(dd);
lcd.print("/");
lcd.print(mm);
lcd.print("/");
lcd.print(yy);
delay(100);
if(digitalRead(next)==0)
{
m=mm;
EEPROM.write(add++, m);
temp=0;
while(digitalRead(next)==0);
}
}
delay(1000);
}
med_remind.ino (8.23 KB)