Buzzer
The Inkplate 4 TEMPERA 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 initBuzzer():
inkplate.initBuzzer();
inkplate.initBuzzer()
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 beep(durationMs):
inkplate.beep(80); // 80ms short beep
inkplate.beep()
Plays a short beep of a specified duration.
Returns value: None
Function parameters:
| Type | Name | Description |
|---|---|---|
int | durationMs | How long the beep should last, in milliseconds. |
Beep with frequency
You can also specify the frequency of the beep to create different tones:
inkplate.beep(300, 750); // 300ms beep at 750Hz
inkplate.beep(300, 2400); // 300ms beep at 2400Hz
inkplate.beep()
Plays a beep with a specified duration and frequency.
Returns value: None
Function parameters:
| Type | Name | Description |
|---|---|---|
int | durationMs | Duration of the beep in milliseconds. |
int | frequencyHz | Approximate frequency of the beep in Hz (between 572 Hz and 2933 Hz). |
Manual on/off control
You can also control the buzzer manually:
inkplate.beepOn(); // Turn buzzer on
delay(200);
inkplate.beepOff(); // Turn buzzer off
inkplate.beepOn()
Turns the buzzer on indefinitely.
Returns value: None
inkplate.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.beep(100, chord[currentNoteIndex]);
delay(600);
} else {
inkplate.beep(100, chord[currentNoteIndex]);
delay(250);
inkplate.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.