# 按鈕模組

## 按鈕模組 <a href="#toc124882502" id="toc124882502"></a>

**專案說明**

使用「Raspberry Pi Pico W」連接「按鈕模組」, 讀取按鈕模組的數值變化。此**按鈕模組**包含於「洞洞五教學材料包」內。

### **按鈕模組電路圖**

* Raspberry Pi Pico W
* Raspberry Pi Pico W 擴充板
* 按鈕模組

**按鈕模組**是**數位訊號**輸入， 可以接「D0\~ D28」的Raspberry Pi Pico擴充板訊號端上。 本範例連接到「D7」

以下介紹兩款按鈕模組的接線圖，一款是上面有金色字體寫著「**digital Push Button Module V2.0**」，另一款模組沒有。

**有**寫「**digital Push Button Module V2.0**」的按鈕模組接線圖

![](/files/AoopWRd8Td7mPnjZRjsb)

**沒有**寫「**digital Push Button Module V2.0**」的按鈕模組接線圖

![](/files/TfYZ3ikzCrVUtGeLWFmY)

### **BlocklyDuino 程式 (Button)**

兩款的程式都是相同的，請見下圖。

![](/files/LNOCo8qz23ktw9OdgzOZ)

### **Arduino 程式(Button.ino)如下**

```
void setup()
{
pinMode(7, INPUT);
Serial.begin(9600);
}
void loop()
{
Serial.println(digitalRead(7));
delay(500);
}
```

### **程式執行結果:**

兩款模組操作上有差異，**有**寫「**digital Push Button Module V2.0**」的按鈕模組接線圖，是**按鈕壓下為1，放開為0。**

而**沒有**寫「**digital Push Button Module V2.0**」的按鈕模組接線圖，是**按鈕壓下為0，放開為1。**

![](/files/N3kR9icJ7waLcIHsx1xi)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cavedu.gitbook.io/cavedu/rk005/module_ui/button.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
