Skip to content

winglander/PiicoDev_Buzzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PiicoDev_Buzzer

An Arduino library for the PiicoDev Buzzer Module, driven over I2C.

It lets you play tones at a chosen frequency and duration, set the volume, and detect the module on the bus.

Installation

Arduino Library Manager

In the Arduino IDE: Sketch → Include Library → Manage Libraries…, then search for PiicoDev_Buzzer and click Install.

Manual

  1. Download this repository as a ZIP (Code → Download ZIP).
  2. In the Arduino IDE: Sketch → Include Library → Add .ZIP Library… and select the downloaded file.
  3. Or clone/copy this folder into your Arduino/libraries/ directory.

Wiring

Connect the PiicoDev Buzzer to your board's I2C pins (SDA / SCL). The default I2C address is 0x5C (all ID switches off).

Quick start

#include <PiicoDev_Buzzer.h>

PiicoDev_Buzzer buzzer;  // default address 0x5C on the Wire bus

void setup() {
  Serial.begin(115200);
  if (buzzer.begin()) {
    Serial.println("PiicoDev Buzzer found");
  } else {
    Serial.println("Buzzer NOT found - check wiring/address switches");
  }
}

void loop() {
  buzzer.tone(440, 300);  // 440 Hz for 300 ms
  delay(500);
}

See examples/ToneSequence for a full sketch.

API

Method Description
PiicoDev_Buzzer(uint8_t address = 0x5C, TwoWire &wire = Wire) Construct with an optional I2C address and bus.
bool begin(uint8_t volume = BUZZER_VOLUME_HIGH) Start I2C, set the volume, and return true if the module responds.
void tone(uint16_t frequency, uint16_t durationMs = 0) Play frequency Hz for durationMs ms. 0 duration plays continuously.
void noTone() Stop the current tone.
void volume(uint8_t level) Set volume: BUZZER_VOLUME_OFF / LOW / HIGH (0 / 1 / 2).
bool isConnected() Return true if the module acknowledges on the bus.

License

MIT

Attribution

"PiicoDev" and the PiicoDev logo are trademarks of Core Electronics Pty Ltd.

About

Arduino library for the PiicoDev Buzzer Module (I2C)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages