> 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/rk001/module_ui/linkit7697_buzzer_p.md).

# 有源蜂鳴器模組

![](https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LaZQFBYOS3O0ksiEmR1%2F-LoyhZ7TGT0i8ZxuGcbY%2F-LoyhbX8c8zcUb40S9Z9%2Flinkit7697_buzzer_p_00.png?generation=1568715213335695\&alt=media)

## LinkIt 7697 專案說明

使用「LinkIt 7697 NANO Breakout」連接「有源蜂鳴器模組」， 每一秒控制有源蜂鳴器模組發出聲音和靜音 。

此**有源蜂鳴器模組**包含於「[**洞洞么教學材料包**](https://www.robotkingdom.com.tw/product/rk-education-kit-001/) 」內 。

### LinkIt 7697 電路圖

* [LinkIt 7697](https://www.robotkingdom.com.tw/product/linkit-7697/)
* LinkIt 7697 NANO Breakout
* 無源蜂鳴器模組

**有源蜂鳴器模組**是**數位訊號**輸出， 可以接「D0 \~ D13」的 LinkIt 7697 NANO Breakout訊號端上。 本範例連接到「**D2**」。

{% hint style="info" %}
蜂鳴器分為「有源蜂鳴器」及「無源蜂鳴器」，「有源蜂鳴器」僅能發出單一頻率的聲音；「無源蜂鳴器」可依據不同的頻率發出不同聲調的聲音。
{% endhint %}

![](https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LaZQFBYOS3O0ksiEmR1%2F-LoyhZ7TGT0i8ZxuGcbY%2F-LoyhbXGPcElumoC193E%2Flinkit7697_buzzer_p_01.png?generation=1568715212947292\&alt=media)

### BlocklyDuino 積木畫布

每一秒控制有源蜂鳴器模組發出聲音和靜音。

![](https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LaZQFBYOS3O0ksiEmR1%2F-LoyhZ7TGT0i8ZxuGcbY%2F-LoyhbXIT7bsdCeB-x0D%2Flinkit7697_buzzer_p_02.png?generation=1568715216939795\&alt=media)

### Arduino 程式

```c
void setup()
{

  pinMode(2, OUTPUT);
}


void loop()
{
  digitalWrite(2, HIGH);
  delay(1000);
  digitalWrite(2, LOW);
  delay(1000);
}
```

## micro:bit 專案說明

使用「micro:bit搭配科易KEYES micro:bit 感測器擴充板 V2」連接「有源蜂鳴器模組」，每一秒控制有源蜂鳴器模組發出聲音和靜音 。

此**有源蜂鳴器模組**包含於「[**洞洞么教學材料包**](https://www.robotkingdom.com.tw/product/rk-education-kit-001/)」內。

### micro:bit電路圖

* [BBC micro:bit 微控制板  ](https://www.robotkingdom.com.tw/product/bbc-microbit-1/)
* [科易KEYES micro:bit 感測器擴充板 V2  ](https://www.robotkingdom.com.tw/product/keyes-microbit-sensor-breakout-v2/)
* 有源蜂鳴器模組

**有源蜂鳴器模組**是**數位訊號**輸出， 可以接「0、 1、 2、 8、 12、13、14、 15、 16、 19、20」的 micro:bit訊號端上。 本範例連接到「**P0**」。

{% hint style="info" %}
蜂鳴器分為「有源蜂鳴器」及「無源蜂鳴器」，「有源蜂鳴器」僅能發出單一頻率的聲音；「無源蜂鳴器」可依據不同的頻率發出不同聲調的聲音。
{% endhint %}

![](https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LaZQFBYOS3O0ksiEmR1%2Fsync%2F9fea731a5eb9e88d3f9f29b731cc25988f0153d3.JPG?generation=1626579698616563\&alt=media)

### Microsoft MakeCode積木畫布

每一秒控制有源蜂鳴器模組發出聲音和靜音 。

![](https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LaZQFBYOS3O0ksiEmR1%2Fsync%2Fd45e0e977b1488e5fc44fc95ba33e8dcc90b3a3e.JPG?generation=1626579692729056\&alt=media)

### JavaScript 程式

```javascript
basic.forever(function () {
    pins.digitalWritePin(DigitalPin.P0, 1)
    basic.pause(1000)
    pins.digitalWritePin(DigitalPin.P0, 0)
    basic.pause(1000)
})
```

## Raspberry Pi Pico 專案說明

使用「Raspberry Pi Pico」連接「無源蜂鳴器模組」, 每一秒控制有源蜂鳴器模組發出聲音和靜音 。此**有源蜂鳴器模組**包含於「[洞洞么教學材料包](https://robotkingdom.com.tw/product/rk-education-kit-001/)」內。

### 有源蜂鳴器模組電路圖

* [Raspberry Pi Pico](https://robotkingdom.com.tw/product/raspberry-pi-pico/)[  ](https://www.robotkingdom.com.tw/product/bbc-microbit-1/)
* [Raspberry Pi Pico擴充板](https://robotkingdom.com.tw/product/pipico-education-kit-001/)[  ](https://www.robotkingdom.com.tw/product/keyes-microbit-sensor-breakout-v2/)
* 有源蜂鳴器模組

> 有源蜂鳴器模組是數位訊號輸出，僅能發出單一頻率的聲音， 可以接「D0 \~ D28」的Raspberry Pi Pico擴充板訊號端上。 本範例連接到「D7」。

<figure><img src="https://1275793585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LaZQFBYOS3O0ksiEmR1%2Fuploads%2Fblek7guMERwzlZVLnc23%2Fimage.png?alt=media&amp;token=bbd6ee76-01bd-44c0-a415-7768a2b821be" alt=""><figcaption></figcaption></figure>

### Arduino IDE程式

> 每一秒控制有源蜂鳴器模組發出聲音和靜音。

Arduino程式(Active\_buzzer.ino)如下:

```arduino
void setup()
{
  pinMode(7, OUTPUT);
}
void loop()
{
  digitalWrite(7, HIGH);
  delay(1000);
  digitalWrite(7, LOW);
  delay(1000);
}
```
