# 按鈕模組

![](/files/-MITYh4qVFrCj-A2LBka)

## **指令**

![](/files/-MITFRqaRqZpMwQvMBCt)

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

```
digitalRead(6);
```

### 範例 BlocklyDuino 積木畫布

當按下按鈕時，LED就會亮，沒按下按鈕時LED則不會亮。

![](/files/-MITFacFT3IcPmSuESxq)

## Arduino 程式

```
void setup()
{
  pinMode(6, INPUT);

}


void loop()
{
  if (0 == 1) {
    digitalWrite(4, 1);

  } else {
    digitalWrite(4, 0);

  }
digitalRead(6);

}
```

## 影片教學:

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


---

# 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/hangeekduino/samplecode/input_module/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.
