Arduino - lcd.setCursor()
Description
Move the LCD cursor's position to new position (row, column); that is, set the location at which subsequent text written to the LCD will be displayed.
Syntax
lcd.setCursor(col, row)
Parameters
- lcd: a variable of type LiquidCrystal
- col: the column at which to position the cursor (with 0 being the first column)
- row: the row at which to position the cursor (with 0 being the first row)
The below image shows LCD coordinate.
Example
Hardware Required
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.
Wiring Diagram
This image is created using Fritzing. Click to enlarge image
Arduino Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(11, 12, 2, 3, 4, 5);
void setup()
{
lcd.begin(16, 2); // set up the LCD 16x2
lcd.print("hello, world!"); // display "hello, world!" at the initial position (0, 0) <-> upper-left corner
lcd.setCursor(10, 1); // move the cursor to the second row, 11th column
lcd.print("HI!"); // display "HI!" at the second row, 11th column
}
void loop()
{
}
See Also
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |