Floppy is project build to play with embedded Linux on Raspberry Pi Zero as part of Embedded Linux course on Comenius University.
This project builds minimal Linux system with support for controlling floppy drives' stepper motors to play music with controls over WiFi / Serial. The system is built using Buildroot.
- Raspberry Pi Zero 2 W
- floppy drive(s) + some 5V DC power source (~0.9A per drive should be sufficient)
- some jumper cables
- Linux with
dockerinstalled - this repository cloned:
git clone --recurse-submodules git@github.com:Aiq0/floppy.git
Connect floppy drive 5V (right) & GND (center) to you 5V DC power source and connect GND to Pi. Also connect Drive Select (6th from left in top row) with GND (bottom row). Then connect Direction (9th from left top) and Step (10th from left top) to any unused GPIO pins on Pi.
Edit build/config/floppy.conf and specify the GPIO pins you used.
You can also edit build/config/hostapd.conf to change WiFi SSID and password.
docker build -t floppy-builder .
docker run --rm -it -v ./build:/build -v ./output:/output floppy-builderThis will create image in build/buildroot/output/images/sdcard.img. Then copy
that image to Pi's SD card (make sure to replace /dev/sdX with CORRECT drive):
dd if=sdcard.img of=/dev/sdX bs=4M status=progressConnect to WiFi network specified in build/config/hostapd.conf and open
http://192.168.9.1/.
Connect via SSH over WiFi or over serial. Default username is root without password.
To play a song, use:
floppy < /songs/your-songSongs are plain text files where each line represents a note command:
channel offset duration frequency
channel- floppy drive number (starting from 0, max number of drives you set infloppy.conf)offset- time in seconds from start when to play the noteduration- time in seconds how long to play the notefrequency- frequency of the note in Hz
Important
Make sure that the offset and duration values are such that notes do not overlap in one channel and that lines are sorted by offset (at least per channel).
Song ends when all notes are played.
0 0.0 2.0 130.81
0 2.0 2.0 146.83
0 4.0 2.0 164.81
0 6.0 2.0 174.61
0 8.0 2.0 196.00
0 10.0 2.0 220.00
0 12.0 2.0 246.94
0 14.0 2.0 261.63
1 1.0 2.0 261.63
1 3.0 2.0 246.94
1 5.0 2.0 220.00
1 7.0 2.0 196.00
1 9.0 2.0 174.61
1 11.0 2.0 164.81
1 13.0 2.0 146.83
1 15.0 2.0 130.81
You can use scripts/midi.py (requires uv or python3 and miditoolkit installed) to convert MIDI files to this format:
./scripts/midi.py input.mid "Trumpet:transposition=-12" "Strings:transposition=-24" > song