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.
IOREF
Reset
3.3V
5V
GND
Vin
A0
to A5
SCL
SDA
AREF
D13
to D0
GND
VCC
SDA
SCL
5V
to 16x2 I2C LCD VCC
GND
to 16x2 I2C LCD GND
SCL
to 16x2 I2C LCD SCL
SDA
to 16x2 I2C LCD SDA
VCC
to Arduino UNO 5V
GND
to Arduino UNO GND
SCL
to Arduino UNO SCL
SDA
to Arduino UNO SDA
/*
* 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.