
Arduino入門
StickS3 のスピーカー関連 API とサンプルプログラムについて。
#include "M5Unified.h"
void setup() {
M5.begin();
M5.Lcd.setRotation(1);
M5.Lcd.setTextDatum(middle_center);
M5.Lcd.setTextFont(&fonts::FreeMonoBold9pt7b);
M5.Lcd.clear();
M5.Lcd.drawString("Speaker", M5.Lcd.width() / 2, M5.Lcd.height() / 2);
delay(100);
}
void loop() {
M5.Speaker.tone(7000, 100); // frequency, duration
delay(1000);
M5.Speaker.tone(4000, 200); // frequency, duration
delay(1000);
}電源投入後、デバイスは 1 秒ごとに異なる周波数の 2 つの音を発生させます。
StickS3 のスピーカー部分では M5Unified ライブラリの Speaker_Class を使用しています。詳細は以下のドキュメントをご参照ください: