Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsMorse code turns letters into short and long signals. Type any message in the Thonny shell and the Pico looks up each letter in a dictionary and plays it on the piezo and its own LED with the proper timing: a dash is three dots long, and the gaps between letters and words are longer still. Pair it with the Arduino Morse decoder to send messages across the room.
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 Morse code sender: type a message, hear and see it (MicroPython)
from machine import Pin, PWM
import time
led = Pin("LED", Pin.OUT) # the Pico's own LED
buzzer = PWM(Pin(15))
UNIT_MS = 120 # one dot; dashes are three units
CODE = {"A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.", "G": "--.", "H": "....",
"I": "..", "J": ".---", "K": "-.-", "L": ".-..", "M": "--", "N": "-.", "O": "---", "P": ".--.",
"Q": "--.-", "R": ".-.", "S": "...", "T": "-", "U": "..-", "V": "...-", "W": ".--", "X": "-..-",
"Y": "-.--", "Z": "--..", "0": "-----", "1": ".----", "2": "..---", "3": "...--", "4": "....-",
"5": ".....", "6": "-....", "7": "--...", "8": "---..", "9": "----."}
def beep(units):
led.value(1); buzzer.freq(700); buzzer.duty_u16(30000)
time.sleep_ms(units * UNIT_MS)
led.value(0); buzzer.duty_u16(0)
time.sleep_ms(UNIT_MS) # gap inside a letter
while True:
msg = input("Message: ").upper()
for ch in msg:
if ch == " ":
time.sleep_ms(4 * UNIT_MS) # word gap (7 units with the gaps around it)
continue
code = CODE.get(ch)
if not code:
continue
print(ch, code)
for s in code:
beep(1 if s == "." else 3)
time.sleep_ms(2 * UNIT_MS) # letter gap (3 units in all)
Normal for a bare piezo; mount it on a small box to resonate.
4 parts: 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 ₹480 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.
Generating musical notes with tone().
Ideas that reuse this build: Morse code decoder and Class Morse practice. 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.