To follow this guide you'll need the following parts:
- A piezo buzzer. Piezo buzzers are like tiny little speakers, but unlike speakers they don't require an amplifier or other complex circuitry to drive them (consequently they aren't nearly as loud as a speaker and amplifier either!). When voltage is applied to the piezo it grows and shrinks in size, and by changing the voltage over time you can make the piezo change shape fast enough to create a pressure wave that your ears interpret as sound.
- A board running CircuitPython or Arduino. If you're controlling piezos from CircuitPython you'll need a board like the Feather M0 basic which can be loaded with CircuitPython firmware. This guide will also show basic piezo code for Arduino too.
- Breadboard and jumper wires. You'll need these parts to connect components to your development board.
Wiring
To connect a piezo buzzer you just need to connect one leg of the buzzer to your board ground, and another leg to a PWM-capable or analog-out output of your board. For the Feather M0 and other M0 boards look for a squiggly line next to a pin to denote that it supports PWM output. For other boards check the guide or documentation to see which pins support PWM output.
Arduino uses an interrupt system for piezos, so you can use any pin.
For example here's how to wire a piezo to a Feather M0:
- One leg of the piezo buzzer (or black wire) to board GND.
- The other leg of the piezo buzzer (or red wire) to board D5 (or any other PWM-capable output).
Text editor powered by tinymce.