MCP CBS
MCP CBS
No:CBS
Interfacing 16X2 LCD with Arduino
DATE:
Aim:
To interface a 16x2 LCD with an Arduino
Procedure:
Step 1: Create a new Project.
Step 2: The program starts by including the Liquid Crystal library, which is required for
interfacing with the LCD.
Step 3: The Liquid Crystal library is initialized with the pin numbers for Register Select
(RS), Enable (EN), and data pins D4, D5, D6, and D7. These pins are connected to your
Arduino to control the LCD.
Step 4: In the setup function, the LCD's number of columns and rows is specified using lcd.
begin (16, 2). This informs the library that you are using a 16x2 LCD.
Step 5: In the loop function, the following actions are performed:
a. lcd.print("CIRCUIT DIGEST"): This displays "CIRCUIT DIGEST" on the first
line of the LCD.
b. lcd.setCursor(0, 1): This moves the cursor to the second line of the LCD (line
1) and sets it to the first column (column 0).
c. lcd.print("www.circuitdigest.com"): This displays "www.circuitdigest.com" on
the second line of the LCD.
d. delay(750): It adds a delay of 750 milliseconds (0.75 seconds) to give you time to
read the displayed text.
e. lcd.scrollDisplayLeft(): This function scrolls the text on the top line of the LCD
to the left.
f. lcd.setCursor(0, 0): The cursor is moved back to the first line for the next
iteration. Step 6: End.
AKSHAYA R 71812201017
Program:
#include <LiquidCrystal.h>
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
lcd.print("hello, world!");
}
void loop() {
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
}
Connection diagram:
Output:
Result:
Thus, interfacing a 16x2 LCD with an Arduino is executed and verified successfully.
AKSHAYA R 71812201017