Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsA first MicroPython program with a real game in it. After a random wait the LED lights and the Pico times how long you take to press; press too early and it flashes to call you out. The best time of the session is remembered.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
main.py# Pico reaction game: wait for the light, press as fast as you can (MicroPython)
from machine import Pin
import time, urandom
led = Pin(15, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_UP)
best = None
def wait_release():
while button.value() == 0:
time.sleep_ms(5)
print("Press the button to start")
while True:
if button.value() == 1:
time.sleep_ms(10)
continue
wait_release()
led.value(0)
start_wait = time.ticks_ms()
delay = 1500 + urandom.getrandbits(12) % 3500
cheated = False
while time.ticks_diff(time.ticks_ms(), start_wait) < delay:
if button.value() == 0:
cheated = True
break
if cheated:
print("Too early! Wait for the light.")
for _ in range(4):
led.toggle(); time.sleep_ms(100)
led.value(0)
wait_release()
continue
led.value(1)
t0 = time.ticks_ms()
while button.value() == 1:
pass
ms = time.ticks_diff(time.ticks_ms(), t0)
led.value(0)
best = ms if best is None or ms < best else best
print("Reaction:", ms, "ms best:", best, "ms")
wait_release()
The button is rotated 90°; legs on the same side are already connected. Turn it.
LED is reversed; flip it. Check the 220 Ω resistor is in series.
6 parts: Tactile Push Button Switch, Through-Hole LED Pack (Pack of 10), Resistor Assortment Kit (30 Values), Raspberry Pi Pico, Solderless Breadboard (830 points) and Dupont Jumper Wires (40 pcs). Tools: Digital Multimeter and Wire Stripper and Cutter. On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 30 minutes. The build on this page has 4 steps.
No. This page has the complete, tested code (main.py).
About ₹521 for the parts at the prices on this page, plus tools if you do not have them. Quantity price breaks lower the cost when you build several.
Current-limiting resistors for LEDs; Pull-ups and debouncing.
Ideas that reuse this build: Arduino version with a display and Simon memory game. They are listed under Take it further on this page.
Your first MicroPython project: temperature and humidity on an OLED.
A web page with ON and OFF buttons that switches a relay over Wi-Fi.
A warm ring light that fades up at dusk and down at dawn.
Turn a Pi and a touchscreen into a home command centre with a clock and to-do list.
Learning project. Check every circuit and the datasheet of each part before you power it up.