Quiz: Adding an OLED Display and Expressive Behaviors¶
Test your understanding of adding an OLED display and expressive behaviors with these review questions.
1. What is an I2C address?¶
- A block of memory holding the on/off state of every pixel before it's sent to a display
- A dedicated chip-select wire that gives one device exclusive access to a bus
- A short numeric identifier that a device listens for before responding to any message on a shared I2C bus
- The fixed number of pixels a display contains, expressed as width by height
Show Answer
The correct answer is C. An I2C address is a short numeric identifier, commonly written in hexadecimal like 0x3C, that a device listens for before responding to any message on the shared two-wire I2C bus. Option A describes a pixel buffer, option B describes SPI's chip-select approach (which I2C does not use), and option D describes display resolution.
Concept Tested: I2C Address
2. What is a frame buffer?¶
- A pixel buffer holding one complete display image, ready to be pushed to the screen all at once
- A communication standard that uses four dedicated wires per device
- A short numeric identifier used to address a device on a shared bus
- A predefined sequence of tone-generation calls that form a melody
Show Answer
The correct answer is A. A frame buffer is the specific pixel buffer used to hold one complete display image in memory, ready to be pushed to the screen all at once via a display refresh, rather than updating individual pixels live on the physical screen. Option B describes SPI protocol, option C describes an I2C address, and option D describes a buzzer melody.
Concept Tested: Frame Buffer
3. How does SPI protocol differ from I2C protocol in this chapter's description?¶
- SPI uses two shared wires and device addresses, while I2C uses a dedicated chip-select wire per device
- I2C requires more wires than SPI because each device needs its own power line
- SPI and I2C are two names for exactly the same communication standard
- SPI typically uses more wires, including a dedicated chip-select line per device, in exchange for higher data transfer speeds than I2C
Show Answer
The correct answer is D. SPI typically uses more wires than I2C — clock, data-out, data-in, and a dedicated chip-select line per device — in exchange for higher data transfer speeds, and because each device gets its own chip-select wire, SPI doesn't need anything equivalent to an I2C address. Option A reverses the two protocols' wiring approaches, option B misstates the wire-count comparison, and option C incorrectly treats them as identical.
Concept Tested: SPI Protocol
4. Why does the chapter recommend non-blocking code instead of using time.sleep_ms() inside a robot's main loop?¶
- sleep_ms() consumes more electrical current than non-blocking timing code
- sleep_ms() freezes the entire program for its duration, preventing sensor reads or motor updates from happening until it finishes
- sleep_ms() cannot be used with the buzzer or the OLED display at the same time
- sleep_ms() only works correctly when cooperative multitasking is disabled
Show Answer
The correct answer is B. sleep_ms() completely freezes the entire program for its duration — no sensor reading, motor update, or display refresh can happen while the Pico is paused inside that call, which is exactly the wrong time for a robot to ignore an approaching obstacle. Option A is not a claim the chapter makes. Option C is false, since sleep_ms() can technically be used with both, and option D reverses the relationship between the two concepts.
Concept Tested: Non Blocking Code
5. In a priority-based behavior tree, what determines which behavior actually runs when multiple behaviors' trigger conditions are true at the same time?¶
- Whichever behavior was added to the code first always runs
- All true behaviors run simultaneously, blended together
- The highest-priority behavior whose trigger condition is currently true runs, and every lower-priority behavior is suspended
- The behavior tree randomly selects one of the true conditions each loop pass
Show Answer
The correct answer is C. In priority-based behavior, behaviors are ranked from most to least important, and the highest-priority behavior whose trigger condition is currently true is the one that runs, with every lower-priority behavior automatically suspended until it doesn't. Option A ignores the ranking scheme entirely, option B contradicts the "one behavior at a time" model, and option D incorrectly introduces randomness where the chapter describes a deterministic rule.
Concept Tested: Priority Based Behavior
6. Using the chapter's choose_emotion() function, a robot reads distance_cm = 8, light_level = 50, and sound_detected = True. Which emotion state does the function return?¶
- "happy"
- "sleepy"
- "curious"
- "alert"
Show Answer
The correct answer is D. The function's first condition checks distance_cm < 10 and sound_detected; since distance_cm is 8 (less than 10) and sound_detected is True, this condition is met first and the function returns "alert" without evaluating the later elif branches. Option A, B, and C would only be reached if the first condition were false, which it is not in this scenario.
Concept Tested: Multi Sensor Fusion
7. A student wires an SSD1306 OLED display to a Pico and runs i2c.scan(), but the returned list is empty. Applying this chapter's troubleshooting guidance, what should the student check first?¶
- The physical wiring of the SDA and SCL lines against the kit's diagram, since an empty scan result almost always points to a wiring problem, not code
- Whether the emotion state logic has a bug
- Whether the frame buffer was cleared with fill(0) before drawing
- Whether the buzzer melody array is formatted correctly
Show Answer
The correct answer is A. The chapter's tip explicitly states that an empty i2c.scan() result means wiring, not code, is the problem, recommending it as the very first check after wiring a new I2C device. Options B, C, and D all involve display or code logic that would only matter after the I2C connection itself is confirmed working, which an empty scan result rules out.
Concept Tested: I2C Protocol
8. A robot's behavior tree ranks behaviors in this order: 1) Safety Stop, 2) Obstacle Avoidance, 3) Line Following, 4) Idle Face. At a given moment, the emergency stop button has not been pressed, no obstacle is detected, but the robot is currently on a line-following course. Which behavior runs?¶
- Safety Stop
- Obstacle Avoidance
- Line Following
- Idle Face
Show Answer
The correct answer is C. Priority-based behavior selects the highest-priority behavior whose trigger condition is currently true; since Safety Stop and Obstacle Avoidance's conditions are both false in this scenario, the tree moves down to Line Following, whose condition (on a line-following course) is true, and it runs. Idle Face (option D) is lower priority and never gets a chance to run once a higher-priority condition is satisfied.
Concept Tested: Behavior Tree
9. A student's robot plays a happy chirp melody using the play_melody() function with time.sleep_ms() calls between notes. During testing, the robot fails to stop in time when an obstacle appears while the melody is playing. What is the most likely cause?¶
- The buzzer's frequency was set incorrectly, causing a timing miscalculation
- sleep_ms() blocks the entire program during each note, so the distance sensor isn't read again until the melody finishes
- The distance sensor's threshold value was set too low
- The behavior tree ranked sound feedback above safety stop
Show Answer
The correct answer is B. The chapter explicitly warns that sleep_ms() completely freezes the entire program for its duration, so a robot playing a melody with sleep_ms() would be functionally blind and unresponsive to sensor readings for that entire time — exactly the failure described. Option A and C misattribute the problem to unrelated values, and option D would be a design choice, not the cause of a blocking delay.
Concept Tested: Non Blocking Code
10. A robot's OLED face is left displaying the exact same static expression for several hours during a classroom demo. Weeks later, a faint ghost of that expression is visible even when a different expression is shown. What does the chapter identify as the preventive measure for this?¶
- Lowering the I2C bus frequency to reduce pixel wear
- Switching from I2C protocol to SPI protocol
- Increasing the contrast setting so pixels wear more evenly
- Building a screen saver mode into any robot that will sit powered on and idle for a long time
Show Answer
The correct answer is D. The chapter's warning explains that a static high-contrast image left in the same pose for hours wears its lit pixels down faster than the pixels around them, leaving a faint permanent ghost, and recommends building a screen saver mode into any robot that will sit powered on and idle for a long time. Options A, B, and C address unrelated hardware settings that do not solve pixel burn-in.
Concept Tested: Screen Saver Mode