-
-
Save parzibyte/e37a60d647c4dfc421f2c9f50ac0c507 to your computer and use it in GitHub Desktop.
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 <Arduino.h> | |
#include <Wire.h> | |
void setup() | |
{ | |
// put your setup code here, to run once: | |
Wire.begin(); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
// put your main code here, to run repeatedly: | |
byte codigoDeRespuesta, direccion; | |
int dispositivosEncontrados = 0; | |
Serial.println("\n\nBuscando dispositivos..."); | |
for (direccion = 1; direccion < 127; direccion++) | |
{ | |
Wire.beginTransmission(direccion); | |
codigoDeRespuesta = Wire.endTransmission(); | |
if (codigoDeRespuesta == 0) | |
{ | |
Serial.print("Dispositivo encontrado en la dirección 0x"); | |
if (direccion < 16) | |
Serial.print("0"); | |
Serial.print(direccion, HEX); | |
dispositivosEncontrados++; | |
} | |
else if (codigoDeRespuesta == 4) | |
{ | |
Serial.print("Error desconocido en la dirección 0x"); | |
if (direccion < 16) | |
Serial.print("0"); | |
Serial.println(direccion, HEX); | |
} | |
} | |
if (dispositivosEncontrados == 0) | |
Serial.println("No se encontró ningún dispositivo"); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment