Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
Buzzer Class Reference

A class to control a buzzer. More...

#include <Buzzer.h>

Public Member Functions

void begin ()
 Initialize the buzzer pin Configures the buzzer pin as a digital output.
 Buzzer (uint8_t pin)
 Construct a new Buzzer object.
void playTone (uint32_t frequency, uint32_t duration)
 Play a tone on the buzzer.
void turnOff ()
 Turn off the buzzer.

Detailed Description

A class to control a buzzer.

This module provides simple control for the buzzer (BUZZER_PIN — GPIO 17).

Buzzer (BUZZER_PIN — GPIO 17)

  • Output-only pin for tone generation using PWM or software toggling.
  • Useful for short alerts, melodies, or feedback tones.

{@

Constructor & Destructor Documentation

◆ Buzzer()

Buzzer::Buzzer ( uint8_t pin)

Construct a new Buzzer object.

Parameters
pinGPIO pin connected to the buzzer

Member Function Documentation

◆ playTone()

void Buzzer::playTone ( uint32_t frequency,
uint32_t duration )

Play a tone on the buzzer.

Generates a square wave at the requested frequency for the specified duration by toggling the buzzer pin.

Play a tone on the buzzer

Parameters
frequencyFrequency of the tone in Hz
durationDuration of the tone in milliseconds

◆ turnOff()

void Buzzer::turnOff ( )

Turn off the buzzer.

Drives the buzzer pin low.


The documentation for this class was generated from the following file: