Bird
Raised Fist0
Arduinoprogramming~20 mins

16x2 LCD with LiquidCrystal library in Arduino - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
LCD Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output on the LCD?

Consider this Arduino code using the LiquidCrystal library to display text on a 16x2 LCD. What will appear on the LCD screen after running this code?

Arduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
  lcd.print("Hello, World!");
  lcd.setCursor(0, 1);
  lcd.print("LCD Test");
}

void loop() {}
AFirst line: (empty)\nSecond line: Hello, World! LCD Test
BFirst line: LCD Test\nSecond line: Hello, World!
CFirst line: Hello, World! LCD Test\nSecond line: (empty)
DFirst line: Hello, World!\nSecond line: LCD Test
Attempts:
2 left
💡 Hint

Remember that lcd.setCursor(col, row) sets the position for the next print.

🧠 Conceptual
intermediate
1:30remaining
What does lcd.begin(16, 2) do?

In the LiquidCrystal library, what is the purpose of the lcd.begin(16, 2) command?

AIt initializes the LCD with 16 columns and 2 rows, setting up the display size.
BIt clears the LCD screen and turns off the backlight.
CIt sets the cursor to the first column and first row.
DIt loads a custom character set into the LCD memory.
Attempts:
2 left
💡 Hint

Think about what parameters begin() takes and what the LCD needs before printing.

🔧 Debug
advanced
2:30remaining
Why does this code not display anything?

Look at this Arduino code snippet. Why does the LCD remain blank after uploading?

Arduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.print("Hello");
  lcd.begin(16, 2);
}

void loop() {}
ABecause <code>lcd.begin()</code> must be called before any <code>lcd.print()</code> calls to initialize the display.
BBecause the <code>loop()</code> function is empty and must contain <code>lcd.display()</code>.
CBecause the pins are incorrectly assigned and need to be changed.
DBecause the LCD backlight is off and must be turned on manually.
Attempts:
2 left
💡 Hint

Think about the order of initialization and printing.

📝 Syntax
advanced
1:30remaining
Which code snippet correctly sets the cursor and prints on second line?

Which of the following code snippets correctly moves the cursor to the start of the second line and prints "Ready" on a 16x2 LCD?

A
lcd.setCursor(0, 2);
lcd.print("Ready");
B
lcd.setCursor(1, 0);
lcd.print("Ready");
C
lcd.setCursor(0, 1);
lcd.print("Ready");
D
lcd.setCursor(1, 1);
lcd.print("Ready");
Attempts:
2 left
💡 Hint

Remember that row numbering starts at 0.

🚀 Application
expert
3:00remaining
How many characters fit on a 16x2 LCD and what happens if you print more?

You have a 16x2 LCD connected and initialized with lcd.begin(16, 2). How many characters can you display at once? What happens if you print a string longer than that?

AYou can display 32 characters total. Printing more characters will overwrite the first line repeatedly.
BYou can display 32 characters total. Printing more characters continues printing off-screen and they are lost (not visible).
CYou can display 16 characters total. Printing more characters causes the LCD to reset.
DYou can display 32 characters total (16 per line). Printing more scrolls the text horizontally on the first line only.
Attempts:
2 left
💡 Hint

Think about how the LCD handles text longer than its display size.

Practice

(1/5)
1. What does the lcd.begin(16, 2) command do in the LiquidCrystal library?
easy
A. It clears the LCD screen.
B. It sets up the LCD screen size to 16 columns and 2 rows.
C. It moves the cursor to the first position.
D. It prints text on the LCD screen.

Solution

  1. Step 1: Understand lcd.begin() function

    The lcd.begin() function initializes the LCD with the number of columns and rows.
  2. Step 2: Apply to given parameters

    Using lcd.begin(16, 2) sets the screen size to 16 columns and 2 rows.
  3. Final Answer:

    It sets up the LCD screen size to 16 columns and 2 rows. -> Option B
  4. Quick Check:

    lcd.begin(16, 2) = sets screen size [OK]
Hint: Remember lcd.begin sets screen size first [OK]
Common Mistakes:
  • Thinking lcd.begin clears the screen
  • Confusing lcd.begin with lcd.print
  • Assuming lcd.begin moves the cursor
2. Which of the following is the correct way to create a LiquidCrystal object for pins 12, 11, 5, 4, 3, 2?
easy
A. LiquidCrystal lcd = (12, 11, 5, 4, 3, 2);
B. LiquidCrystal lcd(2, 3, 4, 5, 11, 12);
C. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
D. LiquidCrystal lcd(12, 11, 5, 4);

Solution

  1. Step 1: Recall LiquidCrystal constructor syntax

    The constructor requires 6 pins: RS, Enable, D4, D5, D6, D7 in order.
  2. Step 2: Match given pins to correct syntax

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2); matches the correct order and number of pins.
  3. Final Answer:

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2); -> Option C
  4. Quick Check:

    Constructor needs 6 pins in order [OK]
Hint: Count pins: constructor needs exactly 6 pins [OK]
Common Mistakes:
  • Using wrong number of pins
  • Wrong pin order
  • Using assignment instead of constructor
3. What will be displayed on the LCD after running this code?
lcd.begin(16, 2);
lcd.setCursor(0, 1);
lcd.print("Hello");
medium
A. Hello on the second row
B. Nothing is displayed
C. Hello on both rows
D. Hello on the first row

Solution

  1. Step 1: Understand lcd.setCursor(0, 1)

    Cursor moves to column 0, row 1 (second row, since rows start at 0).
  2. Step 2: lcd.print("Hello") prints at cursor

    Text "Hello" appears on the second row starting at first column.
  3. Final Answer:

    Hello on the second row -> Option A
  4. Quick Check:

    setCursor(0,1) = second row [OK]
Hint: Rows start at 0, so row 1 is second row [OK]
Common Mistakes:
  • Assuming row 1 is first row
  • Forgetting cursor position before print
  • Expecting text on both rows
4. Identify the error in this code snippet:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
lcd.begin(16, 2);
lcd.setCursor(1, 2);
lcd.print("Hi");
medium
A. Cursor row 2 is invalid for 2-row LCD
B. lcd.begin() is missing
C. lcd.print() syntax is wrong
D. LiquidCrystal object not created properly

Solution

  1. Step 1: Check lcd.setCursor parameters

    Rows are 0 and 1 for a 2-row LCD; row 2 is out of range.
  2. Step 2: Confirm other code parts

    lcd.begin() is present, object created correctly, and print syntax is correct.
  3. Final Answer:

    Cursor row 2 is invalid for 2-row LCD -> Option A
  4. Quick Check:

    Row index must be 0 or 1 for 16x2 LCD [OK]
Hint: Rows start at 0; max row for 2-row LCD is 1 [OK]
Common Mistakes:
  • Using row 2 instead of 0 or 1
  • Forgetting lcd.begin() call
  • Incorrect object creation syntax
5. You want to display the word "Ready" centered on the first row of a 16x2 LCD. Which code snippet correctly sets the cursor before printing?
hard
A. lcd.setCursor(8, 0); lcd.print("Ready");
B. lcd.setCursor(5, 0); lcd.print("Ready");
C. lcd.setCursor(7, 0); lcd.print("Ready");
D. lcd.setCursor(6, 0); lcd.print("Ready");

Solution

  1. Step 1: Calculate starting position for centering

    LCD width is 16 columns; word length is 5 letters. (16 - 5) / 2 = 5.5, round to 6.
  2. Step 2: Set cursor to column 6 on first row (row 0)

    Use lcd.setCursor(6, 0) to start printing "Ready" centered.
  3. Final Answer:

    lcd.setCursor(6, 0); lcd.print("Ready"); -> Option D
  4. Quick Check:

    (16-5)/2 = 5.5 ≈ 6 for centering [OK]
Hint: Center = (screen width - text length) / 2 rounded [OK]
Common Mistakes:
  • Using wrong column for centering
  • Confusing row numbers
  • Not rounding the position
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard