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 librariesimport board, busio, displayio, digitalio, time, terminaliofrom i2cdisplaybus import I2CDisplayBusfrom adafruit_display_text import labelimport adafruit_displayio_ssd1306# Setupdisplayio.release_displays()i2c = busio.I2C(board.GP17, board.GP16)# uses board.SCL and board.SDAdisplay_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.INPUTswitch1.pull = digitalio.Pull.UP# Draw a splash screentext ="Hello World!"text_area = label.Label(terminalio.FONT, text=text, x=30, y=32)display.root_group.append(text_area)time.sleep(1)seconds =0started =FalsewhileTrue:if switch1.value ==False: started =Trueif 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)'''CHALLENGES1. 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 seconds3. Add an RGB LED that glows red when the timer is stopped, green when it is running and flashes blue when it reaches 04. Add a second button that can be used to reset the timer5. Modify the code so that pressing the button again pauses the timer'''