- Max 67.2%
- Python 32.8%
| max | ||
| tools | ||
| config.py | ||
| main.py | ||
| protocol.py | ||
| README.md | ||
| servo.py | ||
Typewriter prop firmware
Raspberry Pi Pico 2 W + 5 servos. A UDP message makes a servo pull its key down and let it back up.
Files
| File | What it is |
|---|---|
config.py |
Edit this. WiFi, UDP port, servo pins and angles |
main.py |
Runs on boot |
servo.py, protocol.py |
Helpers used by main.py |
tools/send.py |
Run on your laptop to test and calibrate |
1. Install MicroPython (once)
- Download the Pico 2 W
.uf2from https://micropython.org/download/RPI_PICO2_W/ - Hold the BOOTSEL button while plugging the Pico into USB. It appears as a drive.
- Drag the
.uf2onto that drive. The Pico reboots into MicroPython.
2. Copy the files
With Thonny (pick "MicroPython (Raspberry Pi Pico)" as the interpreter): open each file and Save as → Raspberry Pi Pico.
Or with mpremote (pip install mpremote):
mpremote cp config.py servo.py protocol.py main.py :
mpremote reset
To change settings later, edit config.py, copy only that file again, and reset.
3. Find the prop's IP address
Connect over USB and open the serial console (Thonny's shell, or mpremote).
After boot it prints:
Connected. IP address: 192.168.1.50 UDP port: 5005
For the show, give the Pico a fixed address so it never changes. Either set
STATIC_IP in config.py, or reserve the address in the router (DHCP reservation).
Onboard LED: blinking = connecting to WiFi, solid = ready.
4. Commands
| Send | Does |
|---|---|
1 |
press servo "1" (down, hold PRESS_TIME_MS, up) |
1 3 or 1,3 |
press several at once |
pos 2 45 |
move servo "2" to 45° and leave it there (calibration) |
off |
all servos back to their off position |
ping |
prop replies pong |
ping 5006 |
prop replies OSC /pong to port 5006 on the sender (used by the Max device's status light) |
Plain text and OSC are both accepted. As OSC: /1, /press 1, /press/1,
/pos 2 45, /off, /ping. Number arguments can be int or float.
5. Calibrating a servo
python3 tools/send.py 192.168.1.50 # interactive mode
> pos 1 10 # try angles until the key is just untouched -> that's "off"
> pos 1 80 # try angles until the key fully strikes -> that's "on"
> 1 # test a full press
Write the angles into config.py, copy it to the Pico, reset.
If a press is too short for the typebar to strike, raise PRESS_TIME_MS
(or press_ms= on just that servo).
6. Max for Live
max/Typewriter.amxd is a ready-made MIDI effect device.
- Drag
Typewriter.amxdonto a MIDI track in Ableton Live. - Enter the prop's IP address (four boxes) and port (
5005). - Click Press to test a servo, All off to release everything.
- Write notes in a clip on that track. Base note (default C3) presses servo 1, the next note up servo 2, and so on, up to Servos (default 5). Velocity and note length don't matter; each note-on is one press.
MIDI passes through the device, so you can put an instrument after it. Settings are saved with the Live set.
Audio trigger device
max/Typewriter Trigger.amxd is an audio effect. Each short burst of
audio presses one random key.
- Queued is the key the next burst will press. When it's sent, the Sent light flashes, Last sent updates, and a new random key is queued straight away. Re-roll picks a different queued key.
- Threshold is the level a burst must reach. The Audio hit light flashes whenever it does, so you can set it while watching the meter.
- Hold is how long after a hit before another one counts, so one burst with small dips doesn't press twice.
- Mode: Manual ignores audio. Send presses the queued key in either mode.
- No repeat stops the same key coming up twice in a row.
- Connection: the device pings the prop every second. The green light
and "Connected" mean the prop is answering; "No reply" means it isn't
(wrong IP or port, prop off, or a firewall blocking the Reply port, 5006).
Needs the firmware from this repo with
ping <port>support. - Audio passes through unchanged.
Both devices send OSC /press N and /off with [udpsend]. To change them,
edit tools/make_m4l.py and run python3 tools/make_m4l.py, or open the
device in Max (the edit button on the device) and change it there.
Each .maxpat next to an .amxd is the same patch for opening in Max on its own.
Test the OSC path from the laptop with python3 tools/send.py <ip> --osc press 1.