Bird
0
0
Arduinoprogramming~20 mins

LCD cursor positioning in Arduino - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
LCD Cursor Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the cursor position after this code?

Given a 16x2 LCD, what will be the cursor position after running this code?

lcd.setCursor(5, 1);

Assume the cursor starts at (0,0).

Arduino
lcd.setCursor(5, 1);
A(5, 1)
B(1, 5)
C(0, 0)
D(15, 1)
Attempts:
2 left
💡 Hint

The first number is the column (x), the second is the row (y).

Predict Output
intermediate
2:00remaining
What does this code print on the LCD?

What will be displayed on the LCD after this code runs?

lcd.setCursor(0, 0);
lcd.print("Hi");
lcd.setCursor(3, 0);
lcd.print("There");
Arduino
lcd.setCursor(0, 0);
lcd.print("Hi");
lcd.setCursor(3, 0);
lcd.print("There");
AHiThere
BHi There
CHi There
D
Hi
There
Attempts:
2 left
💡 Hint

Think about spaces between printed words and cursor positions.

🔧 Debug
advanced
2:00remaining
Why does this code cause an error?

What error will this code cause and why?

lcd.setCursor(16, 0);
lcd.print("Hello");
Arduino
lcd.setCursor(16, 0);
lcd.print("Hello");
ARuntime error: Cursor position out of bounds
BPrints "Hello" starting at column 0
CNo error, prints "Hello" starting at column 16
DSyntax error: Missing semicolon
Attempts:
2 left
💡 Hint

Remember the LCD columns are 0 to 15 for a 16-column display.

📝 Syntax
advanced
2:00remaining
Which option correctly sets the cursor to the second row, fifth column?

Choose the correct code to set the cursor to column 4, row 1 on a 16x2 LCD.

Alcd.setCursor(5, 2);
Blcd.setCursor(1, 4);
Clcd.setCursor(4, 1);
Dlcd.setCursor(3, 0);
Attempts:
2 left
💡 Hint

Remember columns and rows start counting at 0.

🚀 Application
expert
3:00remaining
How many characters fit on a 20x4 LCD and how to position cursor at last character?

A 20x4 LCD has 20 columns and 4 rows. How many characters fit on the screen? And what is the correct cursor position to print at the last character on the last row?

A84 characters; cursor at (20, 4)
B84 characters; cursor at (19, 4)
C80 characters; cursor at (20, 3)
D80 characters; cursor at (19, 3)
Attempts:
2 left
💡 Hint

Count columns * rows for total characters. Remember zero-based indexing for cursor.