
Arduino入門
StopWatch Speaker 関連APIとサンプルプログラム。
#include "M5Unified.h"
void setup() {
auto cfg = M5.config();
M5.begin(cfg);
M5.Display.setTextDatum(middle_center);
M5.Display.setTextFont(&fonts::FreeMonoBold18pt7b);
M5.Display.setTextSize(1);
M5.Display.drawString("Speaker Test", M5.Display.width() / 2,
M5.Display.height() / 2);
}
void loop() {
M5.Speaker.tone(10000, 100);
delay(1000);
M5.Speaker.tone(4000, 20);
delay(1000);
}書き込み後、スピーカーから 10kHz と 4kHz の異なる周波数の音が再生されます。
StopWatch の Speaker 部分では M5Unified ライブラリの Speaker_Class を使用しています。関連APIの詳細は以下のドキュメントを参照してください: