The Adafruit STEMMA Speaker is a small, versatile speaker module that allows for easy audio output integration into various electronic projects. It is designed to be user-friendly and is compatible with a wide range of microcontrollers, including the popular Arduino platform. This speaker is ideal for projects that require sound notifications, simple music playback, or audio feedback to the user.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Connect to 5V power supply |
2 | GND | Connect to ground |
3 | IN | Audio signal input |
4 | NC | No connection (reserved for future use) |
#include <Arduino.h>
const int speakerPin = 9; // Connect the IN pin of the speaker to digital pin 9
void setup() {
pinMode(speakerPin, OUTPUT);
}
void loop() {
// Play a tone on the speaker for 1 second
tone(speakerPin, 440); // A4 note, 440 Hz
delay(1000); // Wait for 1 second
noTone(speakerPin); // Stop the tone
delay(1000); // Wait for 1 second
}
tone()
function in Arduino to generate a simple tone to test the speaker functionality.Q: Can I use the Adafruit STEMMA Speaker with a 3.3V microcontroller? A: Yes, but the volume may be lower compared to using a 5V supply.
Q: Is it possible to play complex sounds or music? A: The speaker can play simple tones and melodies, but it is not suitable for high-fidelity audio playback.
Q: How can I extend the cable for the speaker? A: Use a 3-wire extension with matching connectors, ensuring that the wire gauge can handle the current without significant voltage drop.