pdf-icon

Arduino入門

2. デバイス&サンプル

Basic/Gray/M5GO Speaker

Basic/Gray/M5GO Speaker関連APIとサンプルプログラムについて。

サンプルプログラム

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include "M5Unified.h"
void setup()
{
auto cfg = M5.config();
M5.begin(cfg);
M5.Display.setTextDatum(middle_center);
M5.Display.setTextFont(&fonts::Orbitron_Light_24);
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);
}

サンプルプログラムの動作結果は以下のようになります:

API

Basic/Gray/M5GO の Speaker機能にはM5Unifiedライブラリの Speaker_Class を採用しています。より詳細なAPIリファレンスは以下のドキュメントをご覧ください:

On This Page