Introduction: Basic Arduino LCD Clock
Ever needed an extra clock? Just so happens that you have an Arduino, LCD display, a Breadboard, and some jumper wires about? This 3-step copy-and-paste instructable is great for anyone looking for a simple, useful project, or just for a cool first project or showcase of your skills.
Supplies
Arduino Uno
Arduino LCD Display
Jumper Wires
400-pin [or larger] Breadboard
Arduino IDE
Chromebook, Windows, Linux, or Mac PC
Step 1: Connect LCD Display to Your Arduino
Identify the pins on your LCD display:
- Most LCD displays have 16 pins arranged in two rows.
- The pinout may vary depending on the specific model, so refer to the datasheet or documentation for your LCD display.
Connect the LCD display to the Arduino:
- Connect the VCC pin of the LCD display to the 5V pin on the Arduino.
- Connect the GND pin of the LCD display to the GND pin on the Arduino.
- Connect the SDA pin of the LCD display to the SDA (A4) pin on the Arduino.
- Connect the SCL pin of the LCD display to the SCL (A5) pin on the Arduino.
- If your LCD display has a backlight, connect the positive (+) pin of the backlight to a 5-Volt pin on the Arduino and the negative (-) pin to a Grounding pin on the Arduino.
(Optional) Connect a potentiometer:
- If your LCD display does not have a built-in contrast adjustment, you can use a potentiometer to adjust the contrast.
- Connect one end of the potentiometer to the VCC pin on the LCD display.
- Connect the other end of the potentiometer to the GND pin on the LCD display.
- Connect the middle pin (wiper) of the potentiometer to the VO (contrast) pin on the LCD display.
Video Credit: DroneBot Workshop
Step 2: Test LCD Display
To make sure your LCD display is working, use this basic test code in Arduino IDE.
#include <LiquidCrystal_I2C.h> // Include the LiquidCrystal_I2C library
LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize the LCD object with the I2C address and dimensions
void setup() {
lcd.begin(16, 2); // Initialize the LCD
lcd.print("LCD Display Test"); // Display a test message
delay(2000); // Delay for 2 seconds
lcd.clear(); // Clear the LCD screen
}
void loop() {
lcd.setCursor(0, 0); // Set the cursor to the first row
lcd.print("Hello, World!"); // Display a message on the first row
lcd.setCursor(0, 1); // Set the cursor to the second row
lcd.print("This is a test."); // Display a message on the second row
delay(2000); // Delay for 2 seconds
lcd.clear(); // Clear the LCD screen
delay(1000); // Delay for 1 second
}
If your LCD display isn't working, go back to step one and check everything.
Attachments
Step 3: Code the Clock Part!
Now, all you have to do is code the actual clock!
In the Arduino IDE, write:
#include <LiquidCrystal_I2C.h> // Include the LiquidCrystal_I2C library
LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize the LCD object with the I2C address and dimensions
void setup() {
lcd.begin(16, 2); // Initialize the LCD
lcd.print(" Arduino Clock"); // Display a welcome message
}
void loop() {
// Set the current time
int hours = hour(12);
int minutes = minute(0);
int seconds = second(0);
// Display the time on the LCD
lcd.setCursor(0, 1); // Set the cursor to the second row
lcd.print("Time: ");
lcd.print(hours);
lcd.print(":");
if (minutes < 10) {
lcd.print("0"); // Add leading zero if minutes is less than 10
}
lcd.print(minutes);
lcd.print(":");
if (seconds < 10) {
lcd.print("0"); // Add leading zero if seconds is less than 10
}
lcd.print(seconds);
delay(1000); // Delay for 1 second
lcd.clear(); // Clear the LCD screen
}
Feel free to customize any aspect of this.
You've finished!



