pdf-icon

Arduino入門

2. デバイス&サンプル

Tab5 Speaker

Tab5 の Speakerに関連するAPIとサンプルプログラムです。

サンプルプログラム

コンパイル要件

  • M5Stack board manager version >= 3.2.0
  • Board selection = M5Tab5
  • M5Unified library version >= 0.2.7
  • M5GFX library version >= 0.2.8
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
##include "M5Unified.h"
void setup()
{
M5.begin();
M5.Display.clear(WHITE);
M5.Display.setTextDatum(middle_center);
M5.Display.setTextFont(&fonts::FreeMonoBold24pt7b);
M5.Display.setTextSize(1);
M5.Display.drawString("Speaker Test", M5.Display.width() / 2, M5.Display.height() / 2);
}
void loop()
{
M5.Speaker.tone(10000, 60);
delay(1000);
M5.Speaker.tone(8000, 60);
delay(1000);
M5.Speaker.tone(6000, 60);
delay(1000);
M5.Speaker.tone(4000, 60);
delay(1000);
M5.Speaker.tone(2000, 60);
delay(1000);
}

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

API

Tab5のSpeaker機能ではM5UnifiedライブラリのSpeaker_Classを使用しています。関連APIについては以下のドキュメントを参照してください:

On This Page