pdf-icon

Arduino Quick Start

2. Devices & Examples

6. Applications

StickC-Plus2 Buzzer

M5StickCPlus2 Buzzer related APIs and case programs.

Example

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include "M5StickCPlus2.h" void setup() { auto cfg = M5.config(); StickCP2.begin(cfg); StickCP2.Display.setRotation(1); StickCP2.Display.setTextColor(GREEN); StickCP2.Display.setTextDatum(middle_center); StickCP2.Display.setTextFont(&fonts::Orbitron_Light_24); StickCP2.Display.setTextSize(1); StickCP2.Display.drawString("Buzzer Test", StickCP2.Display.width() / 2, StickCP2.Display.height() / 2); } void loop() { StickCP2.Speaker.tone(10000, 100); delay(1000); StickCP2.Speaker.tone(4000, 20); delay(1000); }

API

M5StickCPlus2 library is based on the M5Unified library, Buzzer part of the driver uses the Speaker_Class in the M5Unified library, more related APIs can refer to the following document:

On This Page