LoginSignup
0
0

More than 5 years have passed since last update.

Adafruit Itsy Bitsy 32u4 - 5V 16MHzを使って圧電ブザーから音を鳴らす

Posted at

Adafruit Itsy Bitsy 32u4 - 5V 16MHzを使って圧電ブザーから音を鳴らしました。手順を記載します。

準備

Adafruit Itsy Bitsy 32u4 - 5V 16MHz
圧電ブザー
ジャンパワイヤ

回路図

Arduino PIN13と圧電ブザーを繋ぎます。
圧電ブザーのもう一方はGNDへ落とします。
001.png

コード

tone関数を使用してドレミを再生します。

#define DELAYMSEC 300 //delay
#define PINNO 13      // ブザーを接続したピン番号

void setup() {
}

int index[21] =
  {131, 147, 165, 175, 196, 220, 247,
   262, 294, 330, 349, 392, 440, 494,
   523, 587, 659, 698, 784, 880, 988};

void loop() {

  for (int j=0; j<3; j++) { 
    for (int i=0; i<7; i++) { 
        tone(PINNO, index[j*7 + i], DELAYMSEC);
        delay(DELAYMSEC);
    }
  }
  delay(1000);
}

テスト

ドレミ・・と音が鳴ればOKです。

参考

組み込みエンジニアでなくても週末にArduinoを使って遊ぶ
圧電ブザーを鳴らせてみよう

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0