A speaker is an electroacoustic transducer that converts an electrical audio signal into a corresponding sound. The most common type of speaker in use today is the dynamic speaker, invented in the early 1920s by Edward W. Kellogg and Chester W. Rice. Speakers are used in a wide variety of applications, including consumer audio systems, public address systems, and portable audio devices. They can range in size from small personal earphones to large professional concert amplifiers.
Pin Number | Description |
---|---|
1 | Positive Terminal (+) |
2 | Negative Terminal (-) |
Q: Can I connect multiple speakers to one output?
Q: What gauge wire should I use for my speakers?
Q: How can I improve the bass response of my speaker?
// Define the pin connected to the speaker
const int speakerPin = 9;
void setup() {
// Initialize the speaker pin as an output
pinMode(speakerPin, OUTPUT);
}
void loop() {
// Play a tone on the speaker
tone(speakerPin, 440); // Play a 440 Hz tone (A4 note)
delay(1000); // Delay for 1 second
noTone(speakerPin); // Stop the tone
delay(1000); // Delay for 1 second
}
Note: The above code uses the tone()
function to generate a square wave of the specified frequency (and hence a tone) on a pin. A simple piezo buzzer is often used with Arduino for such applications, but a speaker can also be used with an appropriate driver circuit to amplify the signal.