Using the STEMMA Piezo Driver Amp with Arduino involves wiring up the adapter to your Arduino-compatible microcontroller, attaching a piezo element to the driver and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the driver VIN.
Here is an Adafruit Metro wired up to the driver using the STEMMA JST-PH connector:
- Board 5V to driver VIN (red wire)
- Board GND to driver GND (black wire)
- Board pin 5 to driver SIG (white wire)
- Driver VO+ to piezo positive (red wire)
- Driver VO- to piezo negative (black wire)
Here is an Adafruit Metro wired up using a solderless breadboard:
- Board 5V to driver VIN (red wire)
- Board GND to driver GND (black wire)
- Board pin 5 to driver SIG (white wire)
- Driver VO+ to piezo positive (red wire)
- Driver VO- to piezo negative (black wire)
Please note: If you are powering the driver from 5VDC, don't set the gain to x3 because the 15V output is higher than the driver is specified for. If you're powering with 5V use 2x gain max to keep the max voltage at 10V.
// SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries // // SPDX-License-Identifier: MIT #define PIEZO_PIN 5 // Pin connected to the piezo buzzer. int toneFreq[] = {262, 294, 330, 349, 392, 440, 494, 523}; int toneCount = 8; void setup() { Serial.begin(115200); Serial.println("Piezo Tone Example"); } void loop() { for (int i=0; i < toneCount; i++) { Serial.print("Playing frequency: "); Serial.println(toneFreq[i]); tone(PIEZO_PIN, toneFreq[i]); delay(250); // Pause for half a second. noTone(PIEZO_PIN); delay(50); } Serial.println(); delay(1000); }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the tone frequencies printed to the Serial Monitor as they are played through the piezo element. Use the gain DIP switch to adjust the gain for the piezo element.
Text editor powered by tinymce.