@TechnoVillage2024 In this video we have tried to use different commands play with the LCD 16X2 module. You can precisely place the characters at any place you want. You can print 2 lines, you can print single line, you can change Cursor styles, even stop displaying the cursor.
LCD connection video • The Secret to Arduino's LCD Interface Exposed
Full Code
/*
LCD 16X2 Cheat Sheet
*/
// include the library code:
#include LiquidCrystal.h
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Node Monitor");
delay(2000);
//Clear the LCD Screen
lcd.clear();
delay(1000);
// set the cursor to column 8, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(8, 1);
delay(3000);
// print a single character 'A' at 2nd Row 8th Column
lcd.write('A');
delay(3000);
// clear the screen
lcd.clear();
delay(2000);
//Bring the cursor to Home i.e 0,0 position
lcd.home();
// Print a message to the LCD in the 2nd Row
lcd.print("Hello, World!");
delay(3000);
// set the cursor to column 0, line 1 (Second Line)
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
delay(1000);
// Print a message to the LCD in the 2nd Row
lcd.print("Node Monitor");
delay(3000);
// clear the screen
lcd.clear();
delay(1000);
// Turn ON the cursor:
lcd.cursor();
delay(3000);
// Turn OFF the cursor:
lcd.noCursor();
delay(3000);
lcd.print("Hi");
delay(3000);
// clear the screen
lcd.clear();
delay(3000);
lcd.print("Cursor blinks");
// Turn on the blinking cursor:
lcd.blink();
delay(3000);
lcd.clear();
lcd.print("Blink Stops");
// Turn off the blinking cursor:
lcd.noBlink();
delay(3000);
lcd.clear();
// Print a message to the LCD
lcd.print("Node Monitor");
delay(3000);
// Turn off the display:
lcd.noDisplay();
delay(2000);
// Turn on the display: It will show the old message
lcd.display();
delay(3000);
lcd.clear();
// set the display to automatically scroll:
//lcd.autoscroll();
char channel[] = "Node Monitor";
for (int i = 0; i less-than 13; i++){
lcd.write(channel[i]);
delay(500);
}
lcd.clear();
// set the cursor to (16,0):
lcd.setCursor(16, 0);
// set the display to automatically scroll:
lcd.autoscroll();
for (int i = 0; i less-than 13; i++){
// Print a message to the LCD
lcd.write(channel[i]);
delay(500);
}
// turn off automatic scrolling
lcd.noAutoscroll();
// scroll 13 positions (string length) to the left
// to move it offscreen left:
for (int positionCounter = 0; positionCounter less-than 16; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(500);
}
// scroll 29 positions (string length + display length) to the right
// to move it offscreen right:
for (int positionCounter = 0; positionCounter less-than 29; positionCounter++) {
// scroll one position right:
lcd.scrollDisplayRight();
// wait a bit:
delay(500);
}
/*
// scroll 16 positions (display length + string length) to the left
// to move it back to center:
for (int positionCounter = 0; positionCounter less-than 16; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}
*/
// delay at the end of the full loop:
delay(1000);
}
void loop() {
}