Buzzer module passief Arduino Deze passieve buzzer geeft een geluid van ongeveer 85 dB wanneer hij wordt aangesloten op een spanning tussen 4 V en 8 V. Deze passieve buzzer heeft een microcontroller nodig om geluid te maken met een PWM-signaal. De buzzer verbruikt ongeveer 30 mA. Spanning: 5 V. Geschikt voor onder andere Arduino.
| Pin | Signaal | Beschrijving |
|---|---|---|
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. |
| Van | Naar | Draad |
|---|---|---|
board:D9 |
x1:PWM |
green |
board:5V |
x1:VCC |
red |
board:GND |
x1:GND |
black |
Dit voorbeeld is geschreven en compile-gecheckt voor de arduino-uno. Codey Online past het voor je aan naar elk ander ondersteund board.
// 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);
}
Beschrijf wat je wilt bouwen. Codey Online schrijft de code, tekent het aansluitschema, compileert het en flasht je board rechtstreeks vanuit de browser.
Gratis starten