> For the complete documentation index, see [llms.txt](https://cavedu.gitbook.io/cavedu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cavedu.gitbook.io/cavedu/hangeekduino/samplecode/output_module/buzzer.md).

# 蜂鳴器模組

![](/files/-MO5a5d8Z-jwKOj7Hh98)

## **指令**

![](/files/-MOEwrn8ZYrgIV8YBcr_)

## **對應的**Arduino 語法

```
tone(5, 1000);
```

使蜂鳴器發出設定好的頻率的聲音，透過迴圈使蜂鳴器發出電話鈴響的聲音。

![](/files/-MOEyLQKIptieteEzqff)

## Arduino 程式

```
int  i;

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

}


void loop()
{
  for (i = 0; i <= 10; i++) {
    tone(5, 2000);
    delay(50);
    tone(5, 1000);
    delay(50);
  }
  noTone(5);
  delay(1000);
}
```

## 影片教學:

{% embed url="<https://www.youtube.com/watch?v=KB_mvKntR4I>" %}
