Bird
0
0
Raspberry Piprogramming~10 mins

Displaying sensor readings on OLED 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 OLED display.

Raspberry Pi
import [1]
Drag options to blanks, or click blank then click option'
Aboard
Btime
Cadafruit_ssd1306
Drandom
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'board' instead of the OLED library.
Importing 'time' or 'random' which are unrelated here.
2fill in blank
medium

Complete the code to initialize the I2C interface for the OLED display.

Raspberry Pi
i2c = [1]()
Drag options to blanks, or click blank then click option'
ASPI
BI2C
CUART
DGPIO
Attempts:
3 left
💡 Hint
Common Mistakes
Using SPI or UART which are different communication protocols.
Using GPIO which is general purpose pins, not a bus.
3fill in blank
hard

Fix the error in the code to create the OLED display object with correct width and height.

Raspberry Pi
display = adafruit_ssd1306.SSD1306_I2C([1], 64, i2c)
Drag options to blanks, or click blank then click option'
A128
B32
C16
D256
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping width and height values.
Using incorrect pixel dimensions.
4fill in blank
hard

Fill both blanks to clear the display and then show the new content.

Raspberry Pi
display.[1]()
display.[2]()
Drag options to blanks, or click blank then click option'
Afill
Bshow
Cclear
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'clear' instead of 'fill' to empty the display.
Using 'update' instead of 'show' to refresh the display.
5fill in blank
hard

Fill both blanks to create a dictionary comprehension that stores sensor readings greater than 50.

Raspberry Pi
filtered_readings = {sensor: value for sensor, value in readings.items() if value {BLANK_1}} {{BLANK_2}}
print(filtered_readings)
Drag options to blanks, or click blank then click option'
A>
B50
C)
D]
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in the condition.
Forgetting to close the print statement with a parenthesis.