I finally wrote up my project for a "poor man's synthesizer/tone maker" for my Pi.
What is it? A simplistic "synthesizer" that you can plug into your Arduino or Raspberry Pi. Use it when you want your project to produce a range of tones, and just want to use a tiny speaker instead of something more elaborate.
It should also work with many other microcontrollers or single-board computers with GPIO pins.
What's the point? My knowledge of electronics is bad, so I couldn't really figure out how to get good amplification on a speaker. Producing a consistent sound also proved to be difficult. Raspbian is not a RTOS (Real Time Operating System), which leads to glitchiness if you try to twiddle the pins directly. Execution of programs can be interrupted at any time, which messes with the timing. I toyed with using the Ultibo unikernel, which worked better, but it still had the occasional problems with thread scheduling. One possible solution would be to dedicate a core to the task, but I could not get that working.
Demo? Yes, on YouTube (https://youtu.be/3DuH876Wv-k)
What you will need
* An ATTiny85 chip, which is actually quite cheap and fun to play with. They are readily available, and only cost a quid. My favourite place to shop is RS Components. See here, which gives you a pack of 5. What I love about these chips is that they do not take up much space on a circuit board, they are 5V tolerant, and can be run off a coin cell for really small projects
* a speaker. I chose a small passive speaker 32 ohm 0.5W 23mm (RS Component number 790-3975). Something similar should be perfectly OK. You can opt for a piezo-electric speaker, although I personally think they sound too harsh.
* An Arduino/Pi, according to taste, breadboard, resistors and accompanying wires.
Link for further information: https://github.com/blippy/rpi/blob/mast ... /README.md