/*
Screens:
1 - Main Home Screen
2 - Manual Seeding
*/
#include <LiquidCrystal_I2C.h>
#include "uRTCLib.h"
//Define Variables
int x, y = 0, hour, screen = 1;
bool atHome;
char daysOfTheWeek[7][12] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
// Define the Main objects
LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 20x4 display
uRTCLib rtc(0x68); // set RTC adress to 0x68 for DS 1307 Module
void setup() {
URTCLIB_WIRE.begin();
lcd.init(); // Initialize the I2C LCD
lcd.clear(); // Clear LCD Screen
lcd.backlight(); // Turn on backlight (In case if not already on)
pinMode(2, INPUT); // Main input switch
rtc.set(0, 16, 17, 1, 8, 4, 24); // Set RTC Data
/*
How to set RTC Time (format)
rtc.set(second, minute, hour, dayOfWeek, dayOfMonth, month, year)
Numbers for day of week (1=Monday, 7=Sunday)
*/
lcd.setCursor(4, 1);
lcd.print("HOME FARMER");
delay(2000);
lcd.clear();
}
void loop() {
x = digitalRead(2); // Assign variable to read Watering input switch
// RTC refresh
rtc.refresh();
switch(screen) {
case 1: // Normal Screen
// LCD Line 1 (Advertisement)
lcd.setCursor(4, 0);
lcd.print("Home Farmer");
// LCD Line 2 (RTC)
// Date
lcd.setCursor(0, 1);
lcd.print(rtc.day());
lcd.print('/');
lcd.print(rtc.month());
lcd.print('/');
lcd.print(rtc.year());
// Day of the Week
lcd.setCursor(14, 1);
lcd.print(" (");
lcd.print(daysOfTheWeek[rtc.dayOfWeek() - 1]);
lcd.print(") ");
// Time (24 Hours)
lcd.setCursor(8, 1);
lcd.print(rtc.hour());
lcd.print(":");
lcd.print(rtc.minute());
lcd.setCursor(10, 1);
lcd.print(" ");
delay(500);
lcd.setCursor(10, 1);
lcd.print(":");
delay(500);
// Screen Shifting if Button at Pin 2 Pressed
if(x == 1) {
screen = 2;
lcd.clear();
delay(200);
}
break;
case 2: // Seeding
// Advertisement
lcd.setCursor(4, 0);
lcd.print("Home Farmer");
// Seeding Question
lcd.setCursor(3, 2);
lcd.print("Start Seeding?");
break;
}
}