# 아두이노

### 설명

코딩의 결과를 물리적으로 확인할 수 있는 것을 피지컬 컴퓨팅이라고 부르고, 아두이노와 같은 작은 컴퓨터를 피지컬 컴퓨팅 도구라고 부릅니다.

아두이노는 크게 6종류의 핀으로 구성되어 있어요.

* **아날로그 핀 (A0\~A5번 핀)** : 아날로그 입력을 받기 위한 핀
* **디지털 핀 (2\~13번 핀)** : 디지털 입력과 출력을 하기 위한 핀
* **PWM 핀** (디지털 핀 중 \~표시가 있는 3, 5, 6, 9, 10, 11번 핀) : 디지털 핀의 기능에 더해 디지털 핀을 사용하여 아날로그 쓰기를 하기 위한 핀
* **GND** : 접지(Ground), 쉽게 생각해 전기의 +와 -중 -라고 생각하면 됨
* **VIN(5V와 같음), 5V, 3.3V** : 각 볼트만큼의 출력, 쉽게 생각해 전기의 +와 -중 +라고 생각하면 됨
* **기타 핀**
  * 디지털 0\~1번 핀 : Serial 통신 중 UART 통신을 위해 사용하는 핀 (Bluetooth, Wi-Fi 등)
  * SCL : I2C 통신 시 클럭 시그널 전송 (Serial Clock)
  * SDA : I2C 통신 시 데이터 전송 (Serial Data)
  * AREF : 아날로그 핀 레퍼런스 전압, 칩이 아날로그 핀 값을 정확히 읽기 위해 참조
  * RES : 리셋(Reset), 5V를 넣으면 아두이노를 재부팅함, 아두이노 본체의 버튼과 같은 역할

각 핀에서 가능한 것과 불가능한 것은 아래 표를 참고하면 돼요.

<table><thead><tr><th width="243"></th><th width="110">아날로그 읽기</th><th width="110">아날로그 쓰기</th><th width="110">디지털 읽기</th><th width="110">디지털 쓰기</th></tr></thead><tbody><tr><td>아날로그 핀 (A0~A5번 핀)</td><td>O</td><td>X</td><td>X</td><td>X</td></tr><tr><td>디지털 핀 (2~13번 핀)</td><td>X</td><td>X</td><td>O</td><td>O</td></tr><tr><td>PWM 핀 (3, 5, 6, 9, 10, 11번 핀)</td><td>X</td><td>O</td><td>O</td><td>O</td></tr></tbody></table>

<table><thead><tr><th width="270"></th><th width="160">아날로그 핀</th><th width="150">디지털 핀</th><th width="160">PWM 핀</th></tr></thead><tbody><tr><td><p><code>@아두이노 N번 핀 입력 설정</code></p><p>+</p><p><code>@아두이노 N번 핀 읽기</code></p></td><td>O (0~1023)<br>아날로그 값을 읽음</td><td>O (0~1)<br>디지털 값을 읽음</td><td>O (0~1)<br>디지털 값을 읽음</td></tr><tr><td><p><code>@아두이노 N번 핀 아날로그 출력 설정</code></p><p>+</p><p><code>@아두이노 N번 핀 아날로그 쓰기</code></p></td><td>X</td><td>X</td><td>O (0~255)<br>아날로그 값을 씀</td></tr><tr><td><p><code>@아두이노 N번 핀 디지털 출력 설정</code></p><p>+</p><p><code>@아두이노 N번 핀 디지털 쓰기</code></p></td><td>X</td><td>O (0~1)<br>디지털 값을 씀</td><td>O (0~1)<br>디지털 값을 씀</td></tr></tbody></table>

각 핀을 사용하는 상황을 예시를 들어 설명해 드릴게요.

* 아날로그 값을 읽어올 때 : 조도센서, 조이스틱 모듈 등 값이 0과 1로 두가지로만 구분된 게 아닌 것
* 디지털 값을 읽어올 때 : 버튼, 자석 감지 센서 등 값이 0과 1로 두가지로만 구분된 것
* 아날로그 값을 쓸 때 : LED의 밝기 조절, 스피커의 소리 크기 조절, 서보 모터 속도 조절 등 값이 0과 1로 두가지로만 구분된 게 아닌 것
* 디지털 값을 쓸 때 : LED를 단순히 켜고 끄기, 릴레이 모듈 켜고 끄기 등 값이 0과 1로 두가지로만 구분된 것

추가적으로 아두이노와 관련된 명칭을 정리해 드릴게요.

* `PWM`은 펄스 폭 변조로, 0과 1로만 데이터 전송이 가능한 디지털 핀을 극복하여 0\~1023까지 아날로그처럼 데이터 전송이 가능하게끔 하는 기술이에요.
* `I2C`는 여러 개의 디바이스(센서, 액츄에이터 등 이론 상 127개까지 가능)를 단 두 개의 선(SCL, SDA)으로 연결할 수 있게 해주는 직렬 통신 프로토콜이에요. LCD나 OLED와 같이 여러 개의 핀을 사용해야 할 때, 핀 사용 개수를 줄이고자 사용해요.


---

# 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/025.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.
