Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsEach capacitive touch module outputs HIGH while a finger is on it. The program checks the four pads in a loop and plays the matching note on a passive buzzer with PWM. Cover the pads with paper keys to make it look like a piano.
Tick anything you already have and the total updates.
Capacitive touch pad: works through thin plastic, glass or wood, so you can hide it inside an enclosure.
Follow the colours: red is power, dark grey is ground, blue is a signal.
main.py# Pico touch piano: four touch pads play four notes (MicroPython)
from machine import Pin, PWM
import time
pads = [Pin(10, Pin.IN), Pin(11, Pin.IN), Pin(12, Pin.IN), Pin(13, Pin.IN)]
NOTES = [262, 294, 330, 392] # C, D, E, G
speaker = PWM(Pin(15))
while True:
played = False
for pad, note in zip(pads, NOTES):
if pad.value():
speaker.freq(note)
speaker.duty_u16(20000)
played = True
break
if not played:
speaker.duty_u16(0)
time.sleep_ms(10)
Ground the enclosure or keep long wires away from the pad.
Normal for a bare piezo; mount it on a small box to resonate.
5 parts: Capacitive Touch Sensor Module (TTP223), Piezo Buzzer (passive), 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 45 minutes. The build on this page has 4 steps.
No. This page has the complete, tested code (main.py).
About ₹499 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.
Capacitive sensing; Generating musical notes with tone().
Ideas that reuse this build: Pico melody player and Touch talking poster. 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.