Bird
0
0
Raspberry Piprogramming~10 mins

LCD display (16x2) with I2C backpack in Raspberry Pi - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the library needed to control the LCD with I2C.

Raspberry Pi
import [1]
Drag options to blanks, or click blank then click option'
AI2C_LCD_driver
Blcd_driver
Csmbus
Dlcd_i2c
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to import from smbus
Using smbus directly
Using wrong library names like lcd_driver or lcd_i2c
2fill in blank
medium

Complete the code to initialize the LCD display object.

Raspberry Pi
lcd = I2C_LCD_driver.[1]()
Drag options to blanks, or click blank then click option'
ALCD
Blcd
Clcd_init
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'LCD' instead of 'lcd'
Trying to call a non-existent function like 'lcd_init'
3fill in blank
hard

Fix the error in the code to display the text 'Hello' on the first line of the LCD.

Raspberry Pi
lcd.[1]('Hello', 1)
Drag options to blanks, or click blank then click option'
Aprint_line
Bdisplay
Clcd_display_string
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using print or print_line which are not valid methods
Using display which is incomplete
4fill in blank
hard

Fill both blanks to clear the LCD and then display 'Bye' on the second line.

Raspberry Pi
lcd.[1]()
lcd.[2]('Bye', 2)
Drag options to blanks, or click blank then click option'
Alcd_clear
Blcd_display_string
Cprint
Dreset
Attempts:
3 left
💡 Hint
Common Mistakes
Using reset instead of lcd_clear
Using print instead of lcd_display_string
5fill in blank
hard

Fill all three blanks to create a function that writes a message on line 1 and clears the display after 3 seconds.

Raspberry Pi
import time

def show_message(msg):
    lcd.[1]()
    lcd.[2](msg, 1)
    time.[3](3)
Drag options to blanks, or click blank then click option'
Alcd_clear
Blcd_display_string
Csleep
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of lcd_display_string
Using time.print instead of time.sleep