#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 7, 6, 5, 4, 3);
RTC_DS1307 RTC;
int buton = 2;
int hareket= 9;
int sayac;
int ldr = A0;
int role = 12;
int asd=9;
char daysOfTheWeek[7][12] = {"Paz", "Pzt", "Sal", "Car", "Per", "Cum", "Cmt"};
void setup () {
pinMode(buton,INPUT);
pinMode(hareket,INPUT);
pinMode(13,OUTPUT);
pinMode(ldr,INPUT);
pinMode(role,OUTPUT);
Wire.begin();
RTC.begin();
lcd.begin(16, 2);
if (! RTC.isrunning()) {
lcd.println("RTC calismiyor");
}
for(int a=0; a<3; a++){
lcd.print("Bekleyiniz.");
delay(500);
lcd.clear();
lcd.print("Bekleyiniz..");
delay(500);
lcd.clear();
lcd.print("Bekleyiniz...");
delay(500);
lcd.clear();
}
lcd.setCursor(0, 0);
lcd.print("Selim...........");
lcd.setCursor(0, 1);
lcd.print("............Emir");
delay (2000);
lcd.clear();
}
void loop () {
digitalWrite(13,LOW);
if(digitalRead(buton)==0){
DateTime now = RTC.now();
lcd.setCursor(0, 0);
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(' ');
lcd.print(" ");
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.setCursor(0, 1);
if (now.hour()<10)
lcd.print('0');
lcd.print(now.hour(), DEC);
lcd.print(':');
if (now.minute()<10)
lcd.print('0');
lcd.print(now.minute(), DEC);
lcd.print(':');
if (now.second()<10)
lcd.print('0');
lcd.print(now.second(), DEC);
delay(100);
lcd.clear();
}
if(digitalRead(buton)==1){
lcd.print("Hareket = ");
lcd.print(sayac);
lcd.setCursor(6,1);
lcd.print("LDR = ");
lcd.print(ldr);
lcd.home();
}
else if(analogRead(ldr)<35 && digitalRead(hareket)==1){
delay(2000);
sayac=sayac+1;
digitalWrite(role,HIGH);
delay(6000);
digitalWrite(role,LOW);
}
else if(digitalRead(hareket)==1){
delay(2000);
sayac=sayac+1;
}
ldr = analogRead(A0);
}