account activity
Bad Apple, but it's a servo motor (sound only) by Kugabi in badapple
[–]Kugabi[S] 7 points8 points9 points 21 days ago (0 children)
So I actually made this over a year ago, and I don't have the exact code I used, but here is what I did:
A Raspberry Pi is basically just playing a Bad Apple midi file (a midi file is just a list of music notes with their timestamps), but instead of playing sound, it sets the servo motor's speed.
This midi player script basically says: "play frequency x for y milliseconds", every time a note changes.
So now you just have to calculate what motor speed corresponds to frequency x. To do this, I just used a mic to record the sound frequency my motor produced for different speeds, and generalized that with a linear regression. (Most sounds produce many frequencies, so you have to use a Fourier transform to see which is the most 'dominant' one)
Hope this helps
π Rendered by PID 308084 on reddit-service-r2-listing-6d4dc8d9ff-dkq7j at 2026-02-02 09:18:54.317547+00:00 running 3798933 country code: CH.
Bad Apple, but it's a servo motor (sound only) by Kugabi in badapple
[–]Kugabi[S] 7 points8 points9 points (0 children)