Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based I2C LCD Timer Display

Image of Arduino UNO Based I2C LCD Timer Display

Circuit Documentation

Summary of the Circuit

This circuit consists of an Arduino UNO microcontroller board interfaced with a 16x2 I2C LCD display. The Arduino UNO is responsible for controlling the display, which shows the elapsed time in 0.1-second increments. The LCD is connected to the Arduino via the I2C communication protocol, utilizing the SDA (Serial Data Line) and SCL (Serial Clock Line) pins for data transfer. The LCD is powered by the 5V output from the Arduino, and both devices share a common ground.

Component List

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Pins Used:
    • IOREF
    • Reset
    • 3.3V
    • 5V
    • GND
    • Vin
    • A0 to A5
    • SCL
    • SDA
    • AREF
    • D13 to D0

16x2 I2C LCD

  • Description: A 16-character, 2-line liquid crystal display with an I2C interface.
  • Pins Used:
    • GND
    • VCC
    • SDA
    • SCL

Wiring Details

Arduino UNO

  • 5V to 16x2 I2C LCD VCC
  • GND to 16x2 I2C LCD GND
  • SCL to 16x2 I2C LCD SCL
  • SDA to 16x2 I2C LCD SDA

16x2 I2C LCD

  • VCC to Arduino UNO 5V
  • GND to Arduino UNO GND
  • SCL to Arduino UNO SCL
  • SDA to Arduino UNO SDA

Documented Code

/*
 * This Arduino sketch initializes a 16x2 I2C LCD and displays
 * the elapsed time in 0.1 second increments. The LCD is connected
 * to the Arduino UNO via the I2C interface using the SDA and SCL pins.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

unsigned long previousMillis = 0;
const long interval = 100; // interval at which to update display (milliseconds)

void setup() {
  // Initialize the LCD with 16 columns and 2 rows
  lcd.begin(16, 2);
  // Turn on the backlight
  lcd.backlight();
  // Print initial message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Elapsed Time:");
}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    lcd.clear(); // Clear the screen before updating
    lcd.setCursor(0, 0);
    lcd.print("Elapsed Time:");
    lcd.setCursor(0, 1);
    float elapsedSeconds = currentMillis / 1000.0;
    lcd.print(elapsedSeconds, 1); // Print elapsed time to 1 decimal place
    lcd.print(" s");
  }
}

The code is written for the Arduino UNO and is responsible for initializing the 16x2 I2C LCD, updating, and displaying the elapsed time since the Arduino started running the sketch. The display is updated every 0.1 seconds as defined by the interval variable.