Bird
0
0
Raspberry Piprogramming~20 mins

LCD display (16x2) with I2C backpack in Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
LCD I2C Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1: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)
AHello, World! on line 1 and Line 2 Text on line 2
BLine 2 Text on line 1 and Hello, World! on line 2
COnly Hello, World! on line 1, line 2 is blank
DOnly Line 2 Text on line 2, line 1 is blank
Attempts:
2 left
💡 Hint
Look at the lcd_display_string method parameters: the string and the line number.
🧠 Conceptual
intermediate
1: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?
A0x50
B0x3F
C0x68
D0x27
Attempts:
2 left
💡 Hint
Common I2C backpack modules usually use either 0x27 or 0x3F.
🔧 Debug
advanced
2: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)
AThe module I2C_LCD_driver is not installed
BThe lcd_display_string method does not exist
CThe class name is capitalized as 'LCD' not 'lcd' in the module
DThe I2C address is incorrect
Attempts:
2 left
💡 Hint
Check the exact class name in the I2C_LCD_driver module.
📝 Syntax
advanced
1: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?
A
lcd = I2C_LCD_driver.LCD()
lcd.clear()
B
lcd = I2C_LCD_driver.LCD()
lcd.lcd_clear()
C
lcd = I2C_LCD_driver.lcd()
lcd.lcd_clear()
D
lcd = I2C_LCD_driver.LCD()
lcd.clear_display()
Attempts:
2 left
💡 Hint
Check the method name for clearing the display in the library.
🚀 Application
expert
1: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?
A32 characters
B64 characters
C2 characters
D16 characters
Attempts:
2 left
💡 Hint
Think about the number of columns and rows multiplied.