CrossGuard
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Buzzer Class Reference

A class to control a buzzer connected to a GPIO pin. More...

#include <Buzzer.h>

Public Member Functions

 Buzzer (int pin)
 Constructs a Buzzer object associated with a specific GPIO pin.
 
void on ()
 Turns the buzzer on by setting the GPIO pin high.
 
void off ()
 Turns the buzzer off by setting the GPIO pin low.
 

Detailed Description

A class to control a buzzer connected to a GPIO pin.

This class provides simple interfaces to turn a buzzer on and off using the specified GPIO pin on a Raspberry Pi or compatible devices. It relies on the pigpio library (or its stub for non-Raspberry Pi environments) for GPIO pin control.

Constructor & Destructor Documentation

◆ Buzzer()

Buzzer::Buzzer ( int pin)
explicit

Constructs a Buzzer object associated with a specific GPIO pin.

Constructor for the Buzzer class.

Initializes the GPIO library if necessary and sets the specified pin as an output for the buzzer control.

Parameters
pinThe GPIO pin number where the buzzer is connected.

Initializes the GPIO pin used by the buzzer and sets it to output mode.

Parameters
pinGPIO pin number connected to the buzzer.

Member Function Documentation

◆ off()

void Buzzer::off ( )

Turns the buzzer off by setting the GPIO pin low.

Turn the buzzer off.

Sets the GPIO pin to low, deactivating the buzzer.

◆ on()

void Buzzer::on ( )

Turns the buzzer on by setting the GPIO pin high.

Turn the buzzer on.

Sets the GPIO pin to high, activating the buzzer.


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