Actuator

๐Ÿ”Š Buzzer

๐Ÿ“Œ Description

A buzzer is a small device that makes sounds when it receives signals. It can beep, buzz, or even play simple tones.

๐ŸŽฏ Use

In our projects, buzzers are used to:

  • Make alarms or warning sounds.
  • Play short melodies or beeps.
  • Give audio signals when something happens.

๐Ÿ‘‰ Think of the buzzer as the robotโ€™s voice โ€” it speaks with sounds instead of words.

Module parameters

Pin nameDescription
GGND (Power Input Negative)
VVCC (Power Input Cathode)
SDigital signal pins
  • Supply voltage: 3.3V/5V

  • Connection: PH2.0 3P terminal

  • Installation method: double screw fixing


๐Ÿ–ฅ๏ธ Code Explanation

import music
import time

midi = music.MIDI(25)       # Connect buzzer to pin 25
while True:
    midi.pitch_time(440, 1000)   # Play tone at 440 Hz for 1 second
    time.sleep_ms(100)           # Pause for 0.1 second
    midi.pitch_time(880, 3000)   # Play tone at 880 Hz for 3 seconds
    time.sleep_ms(100)           # Pause for 0.1 second

Step by Step

  1. import music โ†’ Brings in tools to play sounds.
  2. import time โ†’ Lets us add pauses between sounds.
  3. midi = music.MIDI(25) โ†’ Connects the buzzer to pin 25 of the board.
  4. while True: โ†’ Starts a loop that repeats forever.
  5. midi.pitch_time(440, 1000) โ†’ Plays a sound at 440 Hz (like the note A) for 1 second.
  6. time.sleep_ms(100) โ†’ Waits 0.1 second before the next sound.
  7. midi.pitch_time(880, 3000) โ†’ Plays a higher sound at 880 Hz for 3 seconds.
  8. time.sleep_ms(100) โ†’ Waits again before repeating.

๐Ÿ‘‰ Together, the buzzer plays two tones in a loop: one short low sound, then one longer high sound.


โœ… Conclusion of the Test

    • If the buzzer makes alternating sounds (low then high), the program is working correctly.
    • This test shows how we can control pitch (how high or low the sound is) and duration (how long it plays).
    • Later, we can combine different tones to make alarms, signals, or even simple songs.
On this page