Created
June 24, 2013 09:23
-
-
Save EnsekiTT/5848829 to your computer and use it in GitHub Desktop.
I2Cスキャナ。何がつながってるかわからないので0x00を送って受け取ってくれるかどうかを調べる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> //I2C Arduino Library | |
int i,j; | |
void setup(){ | |
//Initialize Serial and I2C communications | |
Serial.begin(38400); | |
Wire.begin(); | |
j = 0; | |
Serial.println("init"); | |
} | |
void loop(){ | |
Wire.beginTransmission(j); | |
Wire.write(0x00); | |
i = Wire.endTransmission(); | |
if(i == 0){ | |
Serial.print(j,HEX); | |
Serial.print(","); | |
Serial.println(i); | |
} | |
j++; | |
if(j > 0xFF){ | |
Serial.println("Over"); | |
while(1){ | |
delay(1000); | |
} | |
} | |
delay(25); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment