Piezo Buzzer

Piezo buzzerPiezo buzzer detail

TECHNICAL SPECIFICATIONS

  • Model: HNC-1205A.
  • Rated voltage: +5 V.
  • Resonant frequency: 2300 ± 300 Hz.
  • Sound output at 10 cm: ≥ 85 dB.
  • Current consumption: ≤ 30 mA.
  • Operating temperature: -20 °C to +70 °C.

Description

A piezo buzzer is an electroacoustic device that produces sound through mechanical deformation caused by an electric field.

Piezo buzzer circuit

Use

Connection

The module uses a standard 3-pin connector and can be connected to any OUT port on the Trackduino controller.

Programming

The Buzzer block used to work with the piezo buzzer is in the Actuators block group.

Block and generated functionDescription
Buzzer block

tone(int port, int freq);
Starts generating a square wave at the specified frequency on the specified port.

Arguments:
port (int port) — PWM port connected to the buzzer, OUT1–OUT5.
frequency (int freq) — signal frequency in hertz.
Timed buzzer block

tone(int port, int freq, int time);
Starts generating a square wave at the specified frequency and stops after the specified time.

Arguments:
port (int port) — PWM port connected to the buzzer, OUT1–OUT5.
frequency (int freq) — signal frequency in hertz.
milliseconds (int time) — signal duration in milliseconds.

The program pauses at this step until the specified time has elapsed.
Stop buzzer block

noTone(int port);
Stops signal generation on the specified port.

Arguments:
port (int port) — PWM port connected to the buzzer, OUT1–OUT5.

Project example

Doorbell

Doorbell program

Generated code:

void setup()
{
  pinMode( IN1 , INPUT);
}

void loop()
{
  if (buttonRead(IN1))
  {
    tone(OUT1, 750, 1000);
  }
  else
  {
    noTone(OUT1);
  }
}