Bird
0
0

Why does this code fail to display text on the OLED?

medium📝 Debug Q7 of 15
Raspberry Pi - Display and Output
Why does this code fail to display text on the OLED?
from PIL import Image, ImageDraw
from luma.oled.device import ssd1306
from luma.core.interface.serial import i2c

serial = i2c(port=1, address=0x3C)
device = ssd1306(serial)

image = Image.new('1', (device.width, device.height))
draw = ImageDraw.Draw(image)
draw.text((0, 0), 'Hello', fill=255)
# Missing device.display(image) call
ABecause the fill color 255 is invalid
BBecause the font is not loaded
CBecause the text coordinates are out of range
DBecause the image is not sent to the OLED with device.display()
Step-by-Step Solution
Solution:
  1. Step 1: Check if image is displayed

    The code draws text on the image but never calls device.display(image) to show it.
  2. Step 2: Understand display requirement

    Without calling device.display(), the OLED screen remains unchanged and blank.
  3. Final Answer:

    Because the image is not sent to the OLED with device.display() -> Option D
  4. Quick Check:

    Must call device.display(image) to update OLED [OK]
Quick Trick: Always call device.display(image) to show content [OK]
Common Mistakes:
MISTAKES
  • Forgetting to update OLED with display()
  • Misunderstanding fill color meaning
  • Assuming font must be loaded explicitly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes