From 87a84dc4769b690fb44e35028c8db8a13ea1cb4d Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Mon, 18 Mar 2019 08:13:37 +0100 Subject: [PATCH] Added HD44780 compatible LCD to display arbitrary text and the current time. --- constants.h | 15 +++++++++++---- led-ring-clock.ino | 28 +++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/constants.h b/constants.h index 476ac06..3400f3d 100644 --- a/constants.h +++ b/constants.h @@ -12,17 +12,24 @@ #include // IO Pin Assignments -const uint8_t pinLeds = 3; -const uint8_t pinButton = 5; +// moved PINs out of the way of LCD +const uint8_t pinLeds = 6; +const uint8_t pinButton = 7; const uint8_t pinBrightness = 0; // Define MAC Address byte mac[] = { - 0xA8, 0x61, 0x0A, 0x10, 0x24, 0x01 + 0xA8, 0x61, 0x0A, 0x10, 0x24, 0x02 }; +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +// these differ from the libary / example sketch default to avoid Ethernet shield pins +const int rs = 10, en = 9, d4 = 5, d5 = 8, d6 = 3, d7 = 2; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + // NTP Server to use -char* ntp_server = "warpfire.warpzone"; +char* ntp_server = "de.ntp.pool.org"; // Number of LEDs in ring const int ledRingSize = 60; diff --git a/led-ring-clock.ino b/led-ring-clock.ino index 5f8cd82..1e412db 100644 --- a/led-ring-clock.ino +++ b/led-ring-clock.ino @@ -15,6 +15,7 @@ #include #include #include +#include #include "constants.h" @@ -36,6 +37,13 @@ void setup() { // Begin serial port Serial.begin(serialPortBaudRate); + // set up the LCD's number of columns and rows: + lcd.begin(20, 4); + // Print a message to the LCD. + lcd.print("Analoge LED Uhr"); + lcd.setCursor(4, 3); + lcd.print("by Commander1024"); + // Initialize Network and NTP if (Ethernet.begin (mac) == 0) { Serial.println ("Failed to configure Ethernet using DHCP"); @@ -132,7 +140,8 @@ void loop() { // Show clock clearLeds(); showClock(); - + printLCDtime(); + // Check/Renew DHCP Ethernet.maintain (); } @@ -156,6 +165,23 @@ void showClock() { } } +void printLCDtime() { + lcd.setCursor(0, 1); + lcd.print("Zeit: "); + lcd.setCursor(0, 2); + lcd.print(year(now()), DEC); + lcd.print("."); + lcd.print(month(now()), DEC); + lcd.print("."); + lcd.print(day(now()), DEC); + lcd.print(" "); + lcd.print(hour(now()), DEC); + lcd.print(":"); + lcd.print(minute(now()), DEC); + lcd.print(":"); + lcd.print(second(now()), DEC); +} + // Print debugging info over serial void printDebugMessage() { Serial.print("Current date/time: ");