Projects / Pico arpeggiator

Pico arpeggiator

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. PICO

    Wire the knobs

    Each with its ends to 3V3(OUT) and GND, middles to GP26 and GP27.

  2. PICO

    Wire the buzzer

    Plus to GP15, minus to GND.

  3. PICO

    Wire the button

    GP14 to GND.

  4. PICO

    Run the program

    The shell shows the chord name.

  5. PICO

    Press the button

    The notes play up and down.

  6. PICO

    Turn the speed knob

    The notes get faster or slower.

  7. PICO

    Turn the chord knob

    The chord changes between four.

In short

How do you build a pico arpeggiator?

A Pico plays the notes of a chord one after another, up and down, on a passive buzzer, with one knob for the speed and one for the chord, and a button to start and stop. You need Raspberry Pi Pico H, Passive buzzer, Potentiometer 10 kΩ × 2, Tactile push button 6 mm and Breadboard 830 Tie Points. It takes 7 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Speed knob endsPico 3V3(OUT) pin 36 and GND pin 38Knob across 3.3 V
Speed knob middlePico GP26 pin 31ADC0 input
Chord knob endsPico 3V3(OUT) pin 36 and GND pin 38Knob across 3.3 V
Chord knob middlePico GP27 pin 32ADC1 input
Passive buzzer +Pico GP15 pin 20PWM tone output
Passive buzzer -Pico GND pin 38Return
Start buttonPico GP14 pin 19 and GNDStarts and stops the notes

Code

A chord is several notes played together, and an arpeggio plays the same notes one after another. A passive buzzer makes a sound at whatever frequency it is driven at, so the Pico makes a square wave with PWM and changes its frequency for each note. The notes of four chords are stored in a list as frequencies in hertz, and the program steps through the lowest, middle, highest and middle note again, which sounds like a run up and down. The chord knob is read as a number from 0 to 65535 and split into four zones, one for each chord. The speed knob sets how long each note lasts, from 80 to 500 milliseconds. A button starts and stops the playing. The duty of the PWM is kept low, which makes the buzzer quieter, and the sound can still be sharp at close range, so keep the buzzer away from ears and do not leave it playing for long. A small buzzer gives a thin tone, so this is for learning how notes and chords fit together and not for music.

from machine import Pin, PWM, ADC
import time

buzzer = PWM(Pin(15))
speed_knob = ADC(26)
chord_knob = ADC(27)
button = Pin(14, Pin.IN, Pin.PULL_UP)

# Note frequencies in hertz for four chords, lowest note first
CHORDS = [
    ("C major", [262, 330, 392]),
    ("A minor", [220, 262, 330]),
    ("F major", [175, 220, 262]),
    ("G major", [196, 247, 294]),
]
ORDER = [0, 1, 2, 1]                                # up and then down

def note_on(freq):
    buzzer.freq(freq)
    buzzer.duty_u16(20000)                          # quiet enough for a small buzzer

def note_off():
    buzzer.duty_u16(0)

playing = False
step = 0
last_name = ""

while True:
    if button.value() == 0:
        playing = not playing
        if not playing:
            note_off()
        while button.value() == 0:
            time.sleep_ms(10)
        time.sleep_ms(80)

    chord_index = min(3, chord_knob.read_u16() * 4 // 65536)
    name, notes = CHORDS[chord_index]
    if name != last_name:
        print("Chord:", name)
        last_name = name

    if playing:
        length = 80 + speed_knob.read_u16() * 420 // 65535       # 80 to 500 ms per note
        note_on(notes[ORDER[step % 4]])
        time.sleep_ms(length * 8 // 10)             # sound for most of the time
        note_off()
        time.sleep_ms(length * 2 // 10)             # a short gap between notes
        step += 1
    else:
        time.sleep_ms(20)

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Press the buttonNotes begin
Press it againSilence
Speed knob rightLonger notes, slower
Speed knob leftShorter notes, faster
Chord knobFour different sounds

If it does not work

Silent

Check the buzzer is passive and on GP15, and that the button was pressed.

Same chord always

Check the middle wire of the chord knob on GP27.

Too loud

Lower the duty number 20000.

Notes jump around

Check the knob wires are firm.

Button toggles twice

Hold the press less than a second or keep the debounce delay.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the pico arpeggiator?

Raspberry Pi Pico H, Passive buzzer, Potentiometer 10 kΩ × 2, Tactile push button 6 mm and Breadboard 830 Tie Points.

How long does the pico arpeggiator take to build?

About 120 minutes for a intermediate maker, in 7 steps.

How do I know the pico arpeggiator works?

Press the button: Notes begin. Press it again: Silence. Speed knob right: Longer notes, slower.

Silent: what should I check?

Check the buzzer is passive and on GP15, and that the button was pressed.

Same chord always: what should I check?

Check the middle wire of the chord knob on GP27.

Too loud: what should I check?

Lower the duty number 20000.

Notes jump around: what should I check?

Check the knob wires are firm.