This circuit is designed to interface an Arduino UNO with a 16x2 LCD display using the LiquidCrystal library. The LCD is used to display text and the number of seconds since the Arduino was reset. A trimmer potentiometer is included to adjust the contrast of the LCD, and a resistor is used to limit the current to the LCD backlight.
/*
LCD Display Tutorial
This Arduino sketch demonstrates how to use a 16x2 LCD display with the LiquidCrystal library.
The LiquidCrystal library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the
16-pin interface.
Circuit Configuration:
- LCD RS pin to Arduino digital pin 12
- LCD Enable pin to Arduino digital pin 11
- LCD D4 pin to Arduino digital pin 5
- LCD D5 pin to Arduino digital pin 4
- LCD D6 pin to Arduino digital pin 3
- LCD D7 pin to Arduino digital pin 2
- LCD R/W pin to ground (write mode)
- LCD VSS pin to ground
- LCD VDD pin to 5V
- LCD VO pin (contrast control) connected to the wiper of a 10K potentiometer
(other ends of the potentiometer connected to +5V and ground)
- LCD A (anode) pin to 5V through a 220 Ohm resistor for backlight
- LCD K (cathode) pin to ground
The sketch prints "hello, world!" on the first line of the LCD.
On the second line, it displays the number of seconds since the Arduino was reset.
Written for educational purposes. Feel free to use and modify.
*/
#include <LiquidCrystal.h>
// Pin assignments for the LCD interface
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2); // Initialize LCD (16 columns by 2 rows)
lcd.print("hello, world!"); // Print a message to the LCD
}
void loop() {
lcd.setCursor(0, 1); // Move cursor to the second row
lcd.print(millis() / 1000); // Print elapsed seconds since reset
}
This code initializes the LCD and prints "hello, world!" on the first line. The second line of the LCD displays the number of seconds since the Arduino was reset. The LiquidCrystal
library is used to manage the LCD's operations.