I2C 장치
I2C 장치는 각각 address 를 가지고 있는데 명시되어 있지 않은 경우 address 를 직접 찾아야 합니다.
1번부터 255번 까지 모든 address 검사해야 찾을 수 있습니다.
아두이노에서 간단히 I2C 장치의 address 를 찾는 방법을 소개해 드립니다.
#include <Wire.h> void setup() { Serial.begin (115200); while (!Serial) { } Serial.println (); Serial.println ("I2C scanner. Scanning ..."); byte count = 0; Wire.begin(); for (byte i = 1; i < 120; i++) { Wire.beginTransmission (i); if (Wire.endTransmission () == 0) { Serial.print ("Found address: "); Serial.print (i, DEC); Serial.print (" (0x"); Serial.print (i, HEX); Serial.println (")"); count++; delay (10); // maybe unneeded? } // end of good response } // end of for loop Serial.println ("Done."); Serial.print ("Found "); Serial.print (count, DEC); Serial.println (" device(s)."); } // end of setup void loop() {}
I2C LCD address 찾기 결과
I2C LCD 의 어드레스는 0x27 입니다.