💾 Archived View for capsule.adrianhesketh.com › 2019 › 09 › 29 › raspberry-pi-piezo-buzzer-with-go captured on 2024-02-05 at 09:39:00. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
I'm building a burglar alam with my son, using a Raspberry Pi Zero as the micro-controller, and using Go as the programming language.
That's led to me needing a few libraries along the way. Today's library is to play sounds using a piezo buzzer.
You can grab the code from [0]
It's easy enough to make a beep:
pin := rpio.Pin(12) beeper.Beep(pin, 440, time.Millisecond*500)
Or you can play a tune using musical notes and a tempo.
pin := rpio.Pin(12) bpm := 140 m := beeper.NewMusic(pin, bpm) m.Note("A5", beeper.Quaver) m.Note("B5", beeper.Quaver) m.Note("D5", beeper.Quaver) m.Note("B5", beeper.Quaver) m.Note("F#5", beeper.Crotchet) m.Note("F#5", beeper.Crotchet) m.Note("E5", beeper.Crotchet) m.Rest(beeper.Crotchet) m.Note("A5", beeper.Quaver) m.Note("B5", beeper.Quaver) m.Note("D5", beeper.Quaver) m.Note("B5", beeper.Quaver) m.Note("E5", beeper.Crotchet) m.Note("E5", beeper.Crotchet) m.Note("D5", beeper.Quaver) m.Note("C#5", beeper.Quaver) m.Note("B4", beeper.Quaver) m.Rest(beeper.Crotchet) m.Note("A5", beeper.Quaver) m.Note("B5", beeper.Quaver) m.Note("D5", beeper.Quaver) m.Note("B5", beeper.Quaver) m.Note("D5", beeper.Crotchet) m.Note("E5", beeper.Quaver) m.Note("C#5", beeper.Quaver) m.Rest(beeper.Quaver) m.Note("A4", beeper.Quaver) m.Note("E5", beeper.Crotchet) m.Note("D5", beeper.Crotchet)
A Go Security Journey - Gophercon UK 2019
4x4 alphanumeric keypad on the Raspberry Pi with Go