Bird
0
0
Raspberry Piprogramming~10 mins

OLED display with I2C (SSD1306) 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 SSD1306 library.

Raspberry Pi
from adafruit_ssd1306 import [1]
Drag options to blanks, or click blank then click option'
ASSD1306_UART
BSSD1306_SPI
CSSD1306_USB
DSSD1306_I2C
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing SPI or UART classes which are for different communication protocols.
2fill in blank
medium

Complete the code to initialize the I2C bus on Raspberry Pi.

Raspberry Pi
import board
import busio

i2c = busio.[1](board.SCL, board.SDA)
Drag options to blanks, or click blank then click option'
ASPI
BUART
CI2C
DGPIO
Attempts:
3 left
💡 Hint
Common Mistakes
Using SPI or UART which are different communication protocols.
3fill in blank
hard

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

Raspberry Pi
display = SSD1306_I2C([1], 64, i2c)
Drag options to blanks, or click blank then click option'
A32
B128
C16
D256
Attempts:
3 left
💡 Hint
Common Mistakes
Using 64 as width which is actually the height.
4fill in blank
hard

Fill both blanks to clear the display and show the changes.

Raspberry Pi
display.[1](0)
display.[2]()
Drag options to blanks, or click blank then click option'
Afill
Bshow
Cclear
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using clear() which is not a method in this library.
Calling update() instead of show() which is the correct method.
5fill in blank
hard

Fill all three blanks to draw text on the display and update it.

Raspberry Pi
display.text([1], 0, [2], 1)
display.[3]()
Drag options to blanks, or click blank then click option'
A"Hello, Pi!"
B10
Cshow
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Using 20 for y which might place text too low or off screen.
Forgetting to call show() to update the display.