# \[아두이노] 핀 입력 (데이터 읽기)

### 코드

```
@아두이노 {핀 번호}번 핀 읽기
```

***

### 설명

<mark style="color:purple;">`핀 읽기`</mark>는 아두이노와 연결된 핀의 데이터를 읽어오는 코드예요.

더 자세한 내용이 궁금하다면, [아두이노](/arduino/025.md)를 참고해 주세요.

***

### 주의사항

* 핀 모드 설정이 우선되어야 하고, 읽어올 핀의 핀 모드가 입력으로 설정되어 있어야 해요.
* 입력 설정에서 {핀 번호}에 숫자만 쓰면 디지털 핀으로, "A1"과 같이 "A+숫자"를 문자열로 쓰면 아날로그 핀으로 인식해요.
* 디지털 핀의 값은 0과 1로, 아날로그 핀의 값은 0\~1023까지 읽어와요.

***

### 파이썬 대응 코드

아두이노 코드는 파이썬에 대응되는 코드가 없어 제공되지 않아요.

***

### 예시

{% code title="예시 코드" %}

```
@아두이노 "A3"번 핀 입력 설정
@아두이노 6번 핀 입력 설정
(@아두이노 "A3"번 핀 읽기) 보여주기
(@아두이노 6번 핀 읽기) 보여주기
```

{% endcode %}

{% code title="예시 코드의 결과" %}

```
657
0
```

{% endcode %}

***

### 검색 키워드

digitalRead, analogRead


---

# 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://codebook.horang.it/arduino/027.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.
