Bird
Raised Fist0
Arduinoprogramming~20 mins

Custom characters on LCD in Arduino - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
LCD Custom Character Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What does this Arduino LCD code output?

Consider this Arduino code snippet that creates a custom character and displays it on an LCD:

byte smiley[8] = {
  0b00000,
  0b01010,
  0b01010,
  0b00000,
  0b10001,
  0b01110,
  0b00000,
  0b00000
};

void setup() {
  lcd.begin(16, 2);
  lcd.createChar(0, smiley);
  lcd.setCursor(0, 0);
  lcd.write(byte(0));
}

void loop() {}

What will appear on the LCD screen?

Arduino
byte smiley[8] = {
  0b00000,
  0b01010,
  0b01010,
  0b00000,
  0b10001,
  0b01110,
  0b00000,
  0b00000
};

void setup() {
  lcd.begin(16, 2);
  lcd.createChar(0, smiley);
  lcd.setCursor(0, 0);
  lcd.write(byte(0));
}

void loop() {}
ACompilation error due to incorrect byte array size
BThe LCD shows a blank space at the first position
CThe LCD displays a random character at the first position
DA smiling face icon appears at the first position on the LCD
Attempts:
2 left
💡 Hint

Custom characters are stored in CGRAM and displayed by writing their index as a byte.

🧠 Conceptual
intermediate
1:00remaining
How many custom characters can an Arduino LCD typically store?

When using the LiquidCrystal library on a standard 16x2 LCD, how many custom characters can you create and store at the same time?

A8 custom characters
B16 custom characters
C4 custom characters
D32 custom characters
Attempts:
2 left
💡 Hint

Think about the CGRAM memory size in HD44780 compatible LCDs.

🔧 Debug
advanced
2:00remaining
Why does this custom character not display correctly?

Look at this Arduino code snippet:

byte heart[7] = {
  0b00000,
  0b01010,
  0b11111,
  0b11111,
  0b11111,
  0b01110,
  0b00100
};

void setup() {
  lcd.begin(16, 2);
  lcd.createChar(1, heart);
  lcd.setCursor(0, 0);
  lcd.write(byte(1));
}

void loop() {}

The heart shape does not appear as expected on the LCD. What is the most likely cause?

AThe LCD is not initialized with <code>lcd.begin</code>
BThe <code>lcd.write</code> function cannot print custom characters
CThe byte array has only 7 rows instead of 8, causing incorrect display
DThe <code>createChar</code> index 1 is invalid; it must be 0
Attempts:
2 left
💡 Hint

Custom characters require exactly 8 bytes for 8 rows.

📝 Syntax
advanced
1:30remaining
Which option correctly defines a custom character array for LCD?

Choose the correct syntax to define a custom character pattern for an Arduino LCD:

Abyte customChar[8] = {0b00000, 0b01010, 0b10101, 0b01010, 0b00000, 0b00000, 0b00000, 0b00000};
Bbyte customChar[8] = (0b00000, 0b01010, 0b10101, 0b01010, 0b00000, 0b00000, 0b00000, 0b00000);
Cbyte customChar[7] = {0b00000, 0b01010, 0b10101, 0b01010, 0b00000, 0b00000, 0b00000};
Dbyte customChar = {0b00000, 0b01010, 0b10101, 0b01010, 0b00000, 0b00000, 0b00000, 0b00000};
Attempts:
2 left
💡 Hint

Remember how to declare arrays in Arduino (C++).

🚀 Application
expert
2:30remaining
How to display multiple custom characters on LCD simultaneously?

You want to display two different custom characters side by side on a 16x2 LCD using Arduino. You have created two custom characters at indexes 0 and 1. Which code snippet correctly displays both characters on the first row?

Alcd.setCursor(0, 0); lcd.write(0); lcd.write(1);
Blcd.setCursor(0, 0); lcd.write(byte(0)); lcd.write(byte(1));
Clcd.setCursor(0, 0); lcd.print(byte(0)); lcd.print(byte(1));
Dlcd.setCursor(0, 0); lcd.print(0); lcd.print(1);
Attempts:
2 left
💡 Hint

Use write to print custom characters by their byte index.

Practice

(1/5)
1. What is the main purpose of using createChar() in Arduino LCD programming?
easy
A. To clear the LCD screen
B. To define a custom character pattern for the LCD
C. To set the cursor position on the LCD
D. To print a string on the LCD

Solution

  1. Step 1: Understand the function of createChar()

    This function is used to define a new character pattern by specifying pixel rows for the LCD.
  2. Step 2: Compare with other LCD functions

    Functions like clearing the screen, setting cursor, or printing strings are different and not related to defining custom characters.
  3. Final Answer:

    To define a custom character pattern for the LCD -> Option B
  4. Quick Check:

    createChar() defines custom characters [OK]
Hint: Remember: createChar defines, write displays [OK]
Common Mistakes:
  • Confusing createChar with print or clear functions
  • Thinking createChar moves the cursor
  • Assuming createChar prints text directly
2. Which of the following is the correct way to declare a custom character array for createChar()?
easy
A. byte smiley[8] = {0, 10, 0, 0, 17, 14, 0, 0};
B. int smiley[8] = {0, 10, 0, 0, 17, 14, 0, 0};
C. char smiley[5] = {0, 10, 0, 0, 17};
D. byte smiley[7] = {0, 10, 0, 0, 17, 14, 0};

Solution

  1. Step 1: Check data type and array size

    Custom characters require 8 bytes (one for each row) and use the byte type for pixel data.
  2. Step 2: Validate array length and type

    byte smiley[8] = {0, 10, 0, 0, 17, 14, 0, 0}; uses byte type and 8 elements, matching the LCD custom character format.
  3. Final Answer:

    byte smiley[8] = {0, 10, 0, 0, 17, 14, 0, 0}; -> Option A
  4. Quick Check:

    8 bytes array with byte type = correct declaration [OK]
Hint: Custom chars need 8 bytes, not int or fewer elements [OK]
Common Mistakes:
  • Using int instead of byte
  • Using fewer than 8 elements
  • Using char type which is signed and may cause issues
3. What will be the output on the LCD after running this code snippet?
byte heart[8] = {0,10,31,31,31,14,4,0};
lcd.createChar(0, heart);
lcd.setCursor(0,0);
lcd.write(byte(0));
medium
A. The LCD prints the number 0
B. The LCD shows a blank space
C. The code causes a compile error
D. A heart-shaped custom character appears at the top-left corner

Solution

  1. Step 1: Understand createChar and write usage

    The code defines a heart pattern, stores it at position 0, then writes character 0 at cursor (0,0).
  2. Step 2: Predict LCD output

    Writing byte(0) displays the custom character stored at position 0, which is the heart shape.
  3. Final Answer:

    A heart-shaped custom character appears at the top-left corner -> Option D
  4. Quick Check:

    createChar + write(byte(0)) = custom char display [OK]
Hint: write(byte(0)) prints custom char stored at 0 [OK]
Common Mistakes:
  • Expecting numeric 0 to print
  • Forgetting to use byte() cast in write()
  • Assuming createChar prints automatically
4. Identify the error in this code snippet for displaying a custom character:
byte star[8] = {4,14,21,4,4,0,4,0};
lcd.createChar(1, star);
lcd.setCursor(0,0);
lcd.write(1);
medium
A. Missing byte cast in lcd.write(1)
B. Array size is incorrect
C. createChar index must be 0, not 1
D. setCursor parameters are invalid

Solution

  1. Step 1: Check usage of lcd.write()

    When writing a custom character, the index must be cast to byte, so lcd.write(byte(1)) is correct.
  2. Step 2: Verify other parts

    Array size is 8, createChar index 1 is valid (0-7), setCursor(0,0) is valid.
  3. Final Answer:

    Missing byte cast in lcd.write(1) -> Option A
  4. Quick Check:

    Use byte() cast in write() for custom chars [OK]
Hint: Always cast index with byte() in lcd.write() [OK]
Common Mistakes:
  • Not casting index to byte in lcd.write()
  • Thinking createChar index must be zero
  • Assuming setCursor(0,0) is invalid
5. You want to display two different custom characters side by side on the LCD. Which sequence correctly creates and displays them?
hard
A. Define two byte arrays, use createChar(1, char1) and createChar(2, char2), then write(1) and write(2).
B. Define one byte array with 16 elements, use createChar(0, array), then write(0) twice.
C. Define two byte arrays, use createChar(0, char1) and createChar(1, char2), then write(byte(0)) and write(byte(1)) in order.
D. Use createChar(0, char1) twice, then write(0) and write(1).

Solution

  1. Step 1: Understand createChar indexing

    Custom characters are stored in slots 0 to 7. To display two different chars, use two slots, e.g., 0 and 1.
  2. Step 2: Display characters correctly

    Use write(byte(0)) and write(byte(1)) to print the two custom characters side by side.
  3. Final Answer:

    Define two byte arrays, use createChar(0, char1) and createChar(1, char2), then write(byte(0)) and write(byte(1)) in order. -> Option C
  4. Quick Check:

    Two createChar slots + write(byte(index)) = display two chars [OK]
Hint: Use slots 0 and 1, write with byte() cast [OK]
Common Mistakes:
  • Trying to store both chars in one array
  • Using invalid createChar indexes like 2 or higher without checking
  • Not casting index to byte in write()
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