Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include "RTClib.h"
- #include <LiquidCrystal.h>
- #include <Time.h>
- #include <TimeAlarms.h>
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // for LCD
- RTC_DS1307 RTC; // for clock
- void setup () {
- Wire.begin(); // for clock
- RTC.begin(); // for clock
- lcd.begin(20, 4); // for LCD
- pinMode(9, OUTPUT); // Set Pin 9 to Output
- Alarm.alarmRepeat(8,30,0, MorningAlarm); // 8:30am every day
- Alarm.alarmRepeat(17,45,0, EveAlarm); // 5:45pm every day
- }
- void loop () {
- DateTime now = RTC.now(); // for time diplay to LCD
- lcd.setCursor(0, 0); // following lines display time on LCD
- lcd.print(now.year(), DEC);
- lcd.print('/');
- lcd.print(now.month(), DEC);
- lcd.print('/');
- lcd.print(now.day(), DEC);
- lcd.setCursor(0, 1);
- 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);
- }
- void MorningAlarm(){
- digitalWrite(9, HIGH); // should turn on pin 9
- }
- void EveAlarm(){
- digitalWrite(9, LOW); // should turn off pin 9
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement