본문 바로가기

아두이노

아두이노 핀 역할 살펴보기

 

Arduino UNO

 

VCC GND 이런건 기본이니 매우 쉽고

Digital Pin, Analog Pin도 상식으로 이해하기 쉽다.

VIN의 경우

VIN (sometimes labelled "9V"). The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin. 

이렇게 설명하고 있다.

 

아날로그 핀중에서 보면

I2C/SDA, I2C/SCL 이라는게 있는데

In addition to the specific functions listed below, the analog input pins support 10-bit analog-to-digital conversion (ADC) using the analogRead() function. Most of the analog inputs can also be used as digital pins: analog input 0 as digital pin 14 through analog input 5 as digital pin 19. Analog inputs 6 and 7 (present on the Mini and BT) cannot be used as digital pins.

  • I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library (documentation on the Wiring website).

이런 설명을 하고 있다. I2C 통신은 시리얼(UART)통신과는 다른방식으로 통신하는 것인데 동기화 통신이라 시리얼통신처럼 통신속도를 맞출 필요가 없다고 한다. 그럼 보통 이런걸 언제 쓰는가 하면...

I2C LCD모듈

이런 LCD모듈이다. I2C모듈과 아닌 모듈로 나뉘는데 I2C가 아닌경우 핀이 많다. I2C는 VCC, GND 포함 4개면 되니 여러 모듈을 많이 붙이려고 할때 디지털핀을 절약할 수 있는 장점이 있다.

전통적인 1602LCD의 경우

이렇게 무수히 많은 핀을 사용해야 하니 LCD만을 위한 프로젝트가 아니면 쉽게 사용하기가 어렵다.

 

 

그다음에 SCI라는 놈이 있다.

  • SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.

이렇게 설명되고 있는데 I2C통신처럼  SPI 통신인데 4핀을 사용한다. SS, MOSI, MISO, SCK

I2C통신은 무전기처럼 송신, 수신이 동시에 불가능한데, SPI통신은 4핀이나 있어서 그런지 동시에 여러대의 슬레이브에 송수신이 가능하다고 한다. SS는 Slave Select인데 경우에 따라서는 CS(Chip Select)로 쓰기도 한다. MISO는 Master In Slave Out이고 MOSI는 Master Out Slave In, SCK는 Serial Clock이라고 한다. 

알고나니 딱히 어렵진 않다. 그럼 어떤 모듈이 이런 통신을 쓰는가 하고 보니...

뭐이런게 있긴한데

대부분의 센서는 그냥 시리얼통신 아니면 I2C가 흔했다. 그래서 대부분 SPI통신을 지원하긴 하는데 딱히 자주 쓸일이 있는 것 같지는 않다.

 

ESP8266-01

 

nodeMCU 12-E

nodeMCU의 경우도 두개의 SPI통신핀과 1개의 I2C통신핀을 가지고 있다.

 

 

Wemos D1 Mini

초소형인 Wemos D1 Mini의 경우도 I2C와 SPI통신을 모두 지원한다.

그리고 Built-in LED가 GPIO2번 = D4 라는 걸 알아두면 좋다.