Modulo buzzer passivo Arduino Questo buzzer passivo emette un suono di circa 85 dB quando viene collegato a una tensione compresa tra 4 V e 8 V. Questo buzzer passivo richiede un microcontrollore per generare il suono tramite un segnale PWM. Il buzzer consuma circa 30 mA. Tensione: 5 V. Adatto, tra gli altri, per Arduino.
| Pin | Segnale | Descrizione |
|---|---|---|
PWM |
PWM | PWM control input from the microcontroller to generate the buzzer tone. |
VCC |
power | Positive supply for the passive buzzer module, typically 5V. |
GND |
ground | Ground return for the buzzer module and control signal. |
| Da | A | Filo |
|---|---|---|
board:D9 |
x1:PWM |
green |
board:5V |
x1:VCC |
red |
board:GND |
x1:GND |
black |
Questo esempio è stato scritto e verificato in compilazione per arduino-uno. Codey Online lo adatta a qualsiasi altra scheda supportata.
// Passive buzzer module example for Arduino Uno
// Plays a simple melody using the module's PWM input.
const int buzzerPin = 9; // Connected to x1:PWM
void setup() {
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
Serial.println("Passive buzzer module demo starting...");
}
void playTone(int frequency, int durationMs) {
if (frequency > 0) {
tone(buzzerPin, frequency, durationMs);
}
delay(durationMs * 1.30);
noTone(buzzerPin);
}
void loop() {
Serial.println("Playing C major scale...");
int melody[] = {262, 294, 330, 349, 392, 440, 494, 523};
int noteDuration = 180;
for (int i = 0; i < 8; i++) {
Serial.print("Note frequency: ");
Serial.println(melody[i]);
playTone(melody[i], noteDuration);
}
Serial.println("Pausing...");
delay(1000);
}
Descrivi cosa vuoi realizzare. Codey Online scrive il codice, disegna lo schema di collegamento, lo compila e programma la tua scheda direttamente dal browser.
Inizia gratis