Created
March 31, 2020 14:44
-
-
Save nazt/194878bf12d4896157e15003fe2b7103 to your computer and use it in GitHub Desktop.
i2c-scanner.ino
This file contains hidden or 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> | |
void setup() | |
{ | |
Serial.begin (115200); | |
//Wire.begin(19, 26); | |
} | |
void Scanner () | |
{ | |
Serial.println (); | |
Serial.println ("I2C scanner. Scanning ..."); | |
byte count = 0; | |
Wire.begin(); | |
for (byte i = 8; i < 120; i++) | |
{ | |
Wire.beginTransmission (i); // Begin I2C transmission Address (i) | |
if (Wire.endTransmission () == 0) // Receive 0 = success (ACK response) | |
{ | |
Serial.print ("Found address: "); | |
Serial.print (i, DEC); | |
Serial.print (" (0x"); | |
Serial.print (i, HEX); // PCF8574 7 bit address | |
Serial.println (")"); | |
count++; | |
} | |
} | |
Serial.print ("Found "); | |
Serial.print (count, DEC); // numbers of devices | |
Serial.println (" device(s)."); | |
} | |
void loop() | |
{ | |
Scanner (); | |
delay (1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment