3. OLED
What is an OLED?
The display in your box is an OLED display. OLED stands for Organic Light-Emitting Diode. You may have seen this mentioned on advertisements for TVs as many models use this technology.
It's a type of digital display technology that uses LEDs and layers of thin organic film between two electrodes. When electrical current is applied, the display emits light. Our code tells the display where to show light and when.
What is I2C?
I2C, sometimes referred to as IIC, stands for Inter-Integrated Circuit. It's a type of communication protocol which allows multiple I2C devices to communicate to a controller like our Pico.
I2C requires just two wires to communicate (along with 3.3V and GND for our display) and has benefits over some other communication options - but we won't bore you with that just now as it's not going to be relevant until you're much further along on your maker journey.
To use I2C we need to import it in our code, which we'll show you in just two ticks!



# import libraries
import board, busio, displayio, digitalio, time, terminalio
from i2cdisplaybus import I2CDisplayBus
from adafruit_display_text import label
import adafruit_displayio_ssd1306
# Setup
displayio.release_displays()
i2c = busio.I2C(board.GP17, board.GP16) # uses board.SCL and board.SDA
display_bus = I2CDisplayBus(i2c, device_address=0x3c)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=64)
display.root_group = displayio.Group()
switch1 = digitalio.DigitalInOut(board.GP14)
switch1.direction = digitalio.Direction.INPUT
switch1.pull = digitalio.Pull.UP
# Draw a splash screen
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, x=30, y=32)
display.root_group.append(text_area)
time.sleep(1)
seconds = 0
started = False
while True:
if switch1.value == False:
started = True
if started == True:
#clear the display
display.root_group = displayio.Group()
#update time
text_area = label.Label(terminalio.FONT, text=str(seconds), x=60, y=32)
display.root_group.append(text_area)
seconds = seconds + 1
time.sleep(1)
'''
CHALLENGES
1. Change the splash screen so that the user is given instructions on how to use the timer
2. Modify the code so that the timer counts down from 10 seconds
3. Add an RGB LED that glows red when the timer is stopped, green when it is running
and flashes blue when it reaches 0
4. Add a second button that can be used to reset the timer
5. Modify the code so that pressing the button again pauses the timer
'''

Last updated
Was this helpful?