Skip to main content

Buzzer

The Inkplate 4TEMPERA features a small built-in buzzer that can be used for sound effects, notifications, or simple melodies. It supports tone generation and frequency control through software.


Initialization​

Before using the buzzer, it must be initialized with buzzer.init():

inkplate.buzzer.init();

inkplate.buzzer.init()

Initializes the onboard buzzer hardware. Must be called before any beep functions.

Returns value: None


Playing beeps​

Basic beep​

The most straightforward way to produce a sound is by using buzzer.beep(durationMs):

inkplate.buzzer.beep(80); // 80ms short beep

inkplate.buzzer.beep()

Plays a short beep of a specified duration.

Returns value: None

Function parameters:

TypeNameDescription
intdurationMsHow long the beep should last, in milliseconds.

Beep with frequency​

You can also specify the frequency of the beep to create different tones:

inkplate.buzzer.beep(300, 750); // 300ms beep at 750Hz
inkplate.buzzer.beep(300, 2400); // 300ms beep at 2400Hz

inkplate.buzzer.beep()

Plays a beep with a specified duration and frequency.

Returns value: None

Function parameters:

TypeNameDescription
intdurationMsDuration of the beep in milliseconds.
intfrequencyHzApproximate frequency of the beep in Hz (between 572 Hz and 2933 Hz).

Manual on/off control​

You can also control the buzzer manually:

inkplate.buzzer.beepOn(); // Turn buzzer on
delay(200);
inkplate.buzzer.beepOff(); // Turn buzzer off

inkplate.buzzer.beepOn()

Turns the buzzer on indefinitely.

Returns value: None

inkplate.buzzer.beepOff()

Turns the buzzer off.

Returns value: None


Full example​

In the official Inkplate example, a small melody is played using notes from a Cmaj7 chord: C (523 Hz), E (659 Hz), G (783 Hz), and B (987 Hz). It also demonstrates multiple playback methods and variable timing.

The loop alternates between playing single notes and repeated tones to simulate musical phrasing:

int chord[4] = {523, 659, 783, 987};
int currentNoteIndex = 0;
int repeatCounter = 0;

void loop() {
if (repeatCounter < 2) {
inkplate.buzzer.beep(100, chord[currentNoteIndex]);
delay(600);
} else {
inkplate.buzzer.beep(100, chord[currentNoteIndex]);
delay(250);
inkplate.buzzer.beep(50, chord[currentNoteIndex]);
delay(300);
}

currentNoteIndex++;
if (currentNoteIndex >= 4) {
currentNoteIndex = 0;
repeatCounter++;
if (repeatCounter >= 4) {
repeatCounter = 0;
delay(3000);
}
}
}

Inkplate4TEMPERA_Buzzer.ino

Complete example using basic and advanced buzzer control, including tones and melody.