LoginSignup
0
0

More than 1 year has passed since last update.

Arduino で、ブザーを鳴らすサンプルプログラム

Last updated at Posted at 2017-08-07

Arduino Grove の 「ブザー・モジュール」のサンプルです。
「ブザー・モジュール」を、「D4」コネクタに取り付けます。
buzzer_arduino.jpg

プログラム的には、配列とループのサンプルです。

Arduino IDE 上のプログラム

aruduino_aug0801.png

sketch_buzzer.ino
int port_buzzer = 4;

void setup() {
  pinMode(port_buzzer,OUTPUT);

}

void loop() {
  int tt = 300;
  int freq[] = {262,294,330,349,392,440,494,523};

  for(int it=0; it < 8; it++)
  {
 tone(port_buzzer,freq[it],tt);
 delay(tt);
  }

  delay(500);

for(int it=7; 0<= it; it--)
  {
 tone(port_buzzer,freq[it],tt);
 delay(tt);
  }


 delay(2000);

}
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