You are on page 1of 4

LCD I2C MODULE:

Arduino Uno to I2C LCD Module:


Connect Arduino Uno 5V to I2C module VCC.
Connect Arduino Uno GND to I2C module GND.
Connect Arduino Uno A4 to I2C module SDA.
Connect Arduino Uno A5 to I2C module SCL.

CODE:

1. PRINTING NAME AND ROLNO IN ROW 0 AND ROW 1

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

// Set the LCD address (You can find this using I2C scanner)

#define I2C_ADDR 0x27

// Set the LCD dimensions (16x2)

#define LCD_COLUMNS 16

#define LCD_ROWS 2

// Create an LCD object

LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_ROWS);


void setup() {

// Initialize the LCD

lcd.begin();

// Print your name on the first row

lcd.setCursor(0, 0);

lcd.print("Your Name");

// Print your roll number on the second row

lcd.setCursor(0, 1);

lcd.print("Your RollNo");

void loop() {

// Nothing to do in the loop for this example

TASK 2: MAKE TEXT SCROLL ON LCD:


(CONNECTIONS: SAME)
CODE:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27


#define LCD_COLUMNS 16
#define LCD_ROWS 2

LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_ROWS);

char name[] = "Your Name";


char rollNo[] = "Your RollNo";

void setup() {
lcd.begin();
lcd.setCursor(0, 0);
lcd.print(name);
lcd.setCursor(0, 1);
lcd.print(rollNo);
}

void loop() {
// Scroll the text to the left
for (int i = 0; i < (strlen(name) + LCD_COLUMNS); i++) {
lcd.scrollDisplayLeft();
delay(300);
}

// Scroll the second line to the left


lcd.setCursor(LCD_COLUMNS, 1);
for (int i = 0; i < (strlen(rollNo) + LCD_COLUMNS); i++) {
lcd.scrollDisplayLeft();
delay(300);
}

// Pause at the end of the scroll


delay(1000);

// Reset display to the initial position


lcd.clear();
lcd.setCursor(0, 0);
lcd.print(name);
lcd.setCursor(0, 1);
lcd.print(rollNo);

// Pause before starting the next scroll


delay(1000);
}

You might also like