Παραγγελία έως τις 14:00 τις εργάσιμες = αποστολή την ίδια ημέρα 30 ημέρες δικαίωμα υπαναχώρησης Εγγύηση 1 έτους
← Πίσω στην επισκόπηση

Διάγραμμα σύνδεσης και παράδειγμα κώδικα

Έτσι συνδέεις το Μονάδα παθητικού buzzer για Arduino σε ένα Arduino UNO ή ESP32, με ένα παράδειγμα sketch που μπορείς να ανεβάσεις αμέσως.

Αναπαραγωγέας μελωδίας για παθητικό buzzer

Αυτό το έργο δείχνει πώς να δημιουργείτε μουσικούς τόνους με ένα παθητικό buzzer module χρησιμοποιώντας ένα Arduino Uno. Το Arduino εκπέμπει σήματα μεταβλητής συχνότητας μέσω της λειτουργίας tone() για να παίξει μια μουσική κλίμακα. Ανοίξτε το Serial Monitor στα 115200 baud για να δείτε τις συχνότητες που παίζονται αυτή τη στιγμή.

Διάγραμμα σύνδεσης: Μονάδα παθητικού buzzer για Arduino σε ένα Arduino UNO
Διάγραμμα σύνδεσης · Κάνε κλικ για μεγέθυνση
Πίνακας σύνδεσης: Μονάδα παθητικού buzzer για Arduino σε ένα Arduino UNO
Πίνακας σύνδεσης · Κάνε κλικ για μεγέθυνση
Passive_Buzzer_Melody_Player.ino · μεταγλωττισμένο και δοκιμασμένο
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : Passive Buzzer Melody Player
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : Buzzer module passief Arduino
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// Passive Buzzer Module Demo on Arduino Uno
const int BUZZER_PIN = 9;

// Musical notes in Hertz (C major scale: C4 to C5)
const int notes[] = {262, 294, 330, 349, 392, 440, 494, 523};
const int noteCount = sizeof(notes) / sizeof(notes[0]);

void setup() {
  Serial.begin(115200);
  Serial.println(F("Passive Buzzer Demo Starting..."));
}

void loop() {
  Serial.println(F("Playing scale ascending..."));
  for (int i = 0; i < noteCount; i++) {
    Serial.print(F("Tone: "));
    Serial.print(notes[i]);
    Serial.println(F(" Hz"));
    tone(BUZZER_PIN, notes[i], 150);
    delay(200);
  }

  delay(300);

  Serial.println(F("Playing scale descending..."));
  for (int i = noteCount - 1; i >= 0; i--) {
    tone(BUZZER_PIN, notes[i], 150);
    delay(200);
  }

  noTone(BUZZER_PIN);
  delay(1500);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Αναπαραγωγέας μελωδίας με παθητικό buzzer ESP32

Αυτό το παράδειγμα δείχνει πώς να δημιουργείτε μουσικούς ήχους με ένα παθητικό buzzer module χρησιμοποιώντας ένα ESP32. Ο μικροελεγκτής χρησιμοποιεί PWM tone generation για να αναπαράγει επανειλημμένα μια ακολουθία μουσικών νοτών. Συνδέστε το buzzer module απευθείας στην τροφοδοσία, στη γείωση και σε ένα GPIO pin για να ακούσετε τη μελωδία.

Διάγραμμα σύνδεσης: Μονάδα παθητικού buzzer για Arduino σε ένα ESP32 DevKit V1
Διάγραμμα σύνδεσης · Κάνε κλικ για μεγέθυνση
Πίνακας σύνδεσης: Μονάδα παθητικού buzzer για Arduino σε ένα ESP32 DevKit V1
Πίνακας σύνδεσης · Κάνε κλικ για μεγέθυνση
ESP32_Passive_Buzzer_Melody_Player.ino · μεταγλωττισμένο και δοκιμασμένο
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : ESP32 Passive Buzzer Melody Player
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : Buzzer module passief Arduino
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// Pin connected to the passive buzzer's PWM input
const int BUZZER_PIN = 25;

// Frequencies in Hz for a simple arpeggio
const int melody[] = {262, 330, 392, 523};
const int noteDurations[] = {250, 250, 250, 400};

void setup() {
  Serial.begin(115200);
  pinMode(BUZZER_PIN, OUTPUT);
  Serial.println("ESP32 Passive Buzzer Demo Started!");
}

void loop() {
  Serial.println("Playing melody...");
  
  for (int i = 0; i < 4; i++) {
    tone(BUZZER_PIN, melody[i], noteDurations[i]);
    delay(noteDurations[i] * 1.30); // Pause between notes
    noTone(BUZZER_PIN);
  }
  
  delay(2000); // Wait 2 seconds before playing again
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Πρόσφατα προβεβλημένα

Ultra Mini Breadboard Πράσινο - XF-25

Ultra Mini Breadboard Πράσινο - XF-25

€ 0,80
RC Snubber Circuit Κύκλωμα

RC Snubber Circuit Κύκλωμα

€ 1,80