Bird
0
0
Arduinoprogramming~5 mins

LCD cursor positioning in Arduino

Choose your learning style9 modes available
Introduction

We use LCD cursor positioning to control where text appears on the screen. It helps us show messages clearly and neatly.

You want to write text at a specific place on the LCD screen.
You need to update only part of the display without clearing everything.
You want to create menus or forms that look organized.
You want to show data like scores or time in fixed positions.
Syntax
Arduino
lcd.setCursor(column, row);

column starts at 0 for the leftmost position.

row starts at 0 for the top line.

Examples
This moves the cursor to the first column of the first row.
Arduino
lcd.setCursor(0, 0); // Top-left corner
This moves the cursor to column 5 (counting from 0) on the second row.
Arduino
lcd.setCursor(5, 1); // Sixth column, second row
Sample Program

This program shows how to position the cursor on a 16x2 LCD. It prints "Hello, World!" on the top line and "LCD Cursor Pos" on the bottom line.

Arduino
#include <LiquidCrystal.h>

// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2); // Set up the LCD's number of columns and rows
  lcd.setCursor(0, 0); // Move cursor to first column, first row
  lcd.print("Hello, World!");
  lcd.setCursor(0, 1); // Move cursor to first column, second row
  lcd.print("LCD Cursor Pos");
}

void loop() {
  // Nothing here
}
OutputSuccess
Important Notes

If you set the cursor outside the LCD size, text may not show or wrap unexpectedly.

Remember columns and rows start counting from zero, not one.

Summary

Use lcd.setCursor(column, row) to move the cursor.

Columns and rows start at zero.

Positioning helps organize text on the LCD screen.