English
English
简体中文
日本語

Arduino Quick Start

2. Devices & Examples

5. Extensions

6. Applications

PaperMono Buzzer

APIs and example programs for the PaperMono buzzer.

Example Programs

Build Requirements

  • M5Stack Board Manager version >= 3.3.9
  • Board option = M5PaperMono
  • M5Unified library version >= 0.2.20
  • M5GFX library version >= 0.2.27
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include <M5Unified.h>

static void drawScreen()
{
    M5.Display.fillScreen(WHITE);
    M5.Display.setTextColor(RED);
    M5.Display.setTextDatum(middle_center);
    M5.Display.setFont(&fonts::FreeSansBold24pt7b);
    M5.Display.setTextSize(1);
    M5.Display.drawString("PaperMono Buzzer Test", M5.Display.width() / 2, M5.Display.height() / 2);
}

void setup()
{
    M5.begin();
    M5.Display.setEpdMode(epd_mode_t::epd_fast);

    drawScreen();
}

void loop()
{
    M5.Speaker.tone(4000, 200);
    delay(2000);
    M5.Speaker.tone(8000, 200);
    delay(2000);
}

After the device powers on, it plays two tones with different frequencies every 2 seconds.

API

The PaperMono buzzer features use Speaker_Class from the M5Unified library. For more information, refer to the following documentation:

Page Tools
PDF
On This Page