Challenge - 5 Problems
LCD I2C Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the output on the LCD after running this code?
Consider this Python code snippet for a Raspberry Pi connected to a 16x2 LCD with an I2C backpack. What text will appear on the first line of the LCD?
Raspberry Pi
import I2C_LCD_driver lcd = I2C_LCD_driver.LCD() lcd.lcd_display_string("Hello, World!", 1) lcd.lcd_display_string("Line 2 Text", 2)
Attempts:
2 left
💡 Hint
Look at the lcd_display_string method parameters: the string and the line number.
✗ Incorrect
The lcd_display_string method takes the text and the line number (1 or 2). The first call writes "Hello, World!" on line 1, the second call writes "Line 2 Text" on line 2.
🧠 Conceptual
intermediate1:00remaining
Which I2C address is most commonly used for a 16x2 LCD with I2C backpack?
You want to communicate with a 16x2 LCD using I2C on Raspberry Pi. Which I2C address is typically used by these backpacks?
Attempts:
2 left
💡 Hint
Common I2C backpack modules usually use either 0x27 or 0x3F.
✗ Incorrect
Most 16x2 LCD I2C backpacks use the address 0x27 by default. Some use 0x3F, but 0x27 is more common.
🔧 Debug
advanced2:00remaining
Why does this code raise an error when initializing the LCD?
Look at this code snippet. It raises an AttributeError: module 'I2C_LCD_driver' has no attribute 'lcd'. What is the cause?
Raspberry Pi
import I2C_LCD_driver lcd = I2C_LCD_driver.lcd() lcd.lcd_display_string("Test", 1)
Attempts:
2 left
💡 Hint
Check the exact class name in the I2C_LCD_driver module.
✗ Incorrect
The class in I2C_LCD_driver is named 'LCD' with uppercase letters, not 'lcd'. Python is case-sensitive, so calling 'lcd()' causes AttributeError.
📝 Syntax
advanced1:30remaining
Which option correctly initializes the LCD and clears the display?
You want to initialize the LCD and clear any previous text. Which code snippet is correct?
Attempts:
2 left
💡 Hint
Check the method name for clearing the display in the library.
✗ Incorrect
The method to clear the LCD in I2C_LCD_driver is 'lcd_clear()'. The class name is 'LCD'.
🚀 Application
expert1:00remaining
How many characters can you display on a 16x2 LCD at once?
You have a 16x2 LCD connected via I2C. How many characters can you show on the screen at the same time?
Attempts:
2 left
💡 Hint
Think about the number of columns and rows multiplied.
✗ Incorrect
A 16x2 LCD has 16 columns and 2 rows, so it can display 16 * 2 = 32 characters simultaneously.
