It shows the time, and date on the first line. And "Cruz's Backpack" on the second line. I was thinking of having it switch back and forth between my name and the class period, like every 5 seconds. Any code ideas? I'd appreciate it. I'm also posting a picture of my setup, and my full code
Code: Select all
// Date and time functions using just software, based on millis() & timer
#include "LiquidCrystal.h"
#include <Wire.h>
#include "RTClib.h"
#define LCD_I2C_ADDR 0
#define LCD_COLUMNS 16
#define LCD_ROWS 2
#define DATE_ROW 0
#define DATE_COL 0
#define TIME_ROW 0
#define TIME_COL 8
#define BANNER_ROW 1
#define BANNER_COL 1
RTC_Millis RTC;
LiquidCrystal lcd(LCD_I2C_ADDR);
RTC_DS1307 rtc;
void setup () {
Serial.begin(57600);
Wire.begin();
// initialize the LCD
lcd.begin(LCD_COLUMNS, LCD_ROWS);
lcd.setBacklight(HIGH);
lcd.clear();
// following line sets the RTC to the date & time this sketch was compiled
// RTC.begin(DateTime(__DATE__,__TIME__));
lcd.setCursor(BANNER_COL, BANNER_ROW);
lcd.print("Cruz's BackPack");
}
void print_padded_digit(int value) {
if (value < 10) {
lcd.print('0');
}
lcd.print(value, DEC);
}
//! Print the month, day, and time to the LCD.
/*!
Prints the date in mm/dd format and the time in HH:MM:SS to the LCD.
\param now the current date and time
*/
void print_date_time(DateTime *now) {
lcd.setCursor(DATE_COL, DATE_ROW);
print_padded_digit(now->month());
lcd.print('/');
print_padded_digit(now->day());
lcd.setCursor(TIME_COL, TIME_ROW);
print_padded_digit(now->hour());
lcd.print(':');
print_padded_digit(now->minute());
lcd.print(':');
print_padded_digit(now->second());
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(" seconds since 1970: ");
Serial.println(now.unixtime());
// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now.unixtime() + 7 * 86400L + 30);
Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
Serial.println();
delay(1000);
print_date_time(&now);
}