periferie/TZXduino/i2c-scanner

I2C Scanner

Pokud máte zařízení, kde si nejste jisti podřízenou adresou, můžete spustit sketch, viz níže. Vyhledá každou možnou adresu (od 1 do 119) a pokud zařízení reaguje, vytiskne tuto adresu.

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011
#include 
void setup() {
  Serial.begin (115200);
  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }
  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; 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 (1);  // 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() {}

Příklad výstupu:

I2C scanner. Scanning ...
Found address: 42 (0x2A)
Done.
Found 1 device(s).  


 

Stránka byla už zobrazena: 61 ×
  Aktualizováno: 1. 6. 2018, 09:52



     psp-ikona.gif, 2 kB    Text to HTML converter and formatter  builder_ikonka.gif, 3 kB
           
  Best Old Games      kabelmanie.gif, 2 kB  root_ico.gif, 2 kB  český diskmag pro počítače ZX Spectrum a kompatibilní
synapse.gif, 4 kB   TuningPC.cz - Vše pro tuning a casemodding vašeho PC        pspad88x31.gif  delphix.gif, 1 kB
sgatlantis_88x31_3.jpg, 4 kB  atlan.gif, 22 kB  arkon.jpg, 12 kB  ico_abeceda.gif, 888B  blog.idnes.cz   
           
       
 
  torry_logo.gif, 4 kB  

Stránka načtena za 0.00131 sekund.