fork(1) download
  1. #include <Wire.h>
  2.  
  3. void setup()
  4. {
  5. Wire.begin();
  6. Serial.begin(115200);
  7. Serial.println("\nI2C Scanner");
  8. }
  9.  
  10.  
  11. void loop()
  12. {
  13. i2c_check();
  14. delay(2500);
  15. }
  16.  
  17. void i2c_check()
  18. {
  19. byte error, address;
  20. int nDevices;
  21.  
  22. Serial.println("Scanning...");
  23.  
  24. nDevices = 0;
  25. for(address = 1; address < 127; address++ )
  26. {
  27. Wire.beginTransmission(address);
  28. error = Wire.endTransmission();
  29.  
  30. if (error == 0)
  31. {
  32. Serial.print("I2C device found at address 0x");
  33. if (address<16) Serial.print("0");
  34. Serial.print(address,HEX);
  35. Serial.println(" !");
  36.  
  37. nDevices++;
  38. }
  39. else if (error==4)
  40. {
  41. Serial.print("Unknow error at address 0x");
  42. if (address<16) Serial.print("0");
  43. Serial.println(address,HEX);
  44. }
  45. }
  46. if (nDevices == 0) Serial.println("No I2C devices found\n");
  47. else Serial.println("done\n");
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:18: fatal error: Wire.h: No such file or directory
 #include <Wire.h>
                  ^
compilation terminated.
stdout
Standard output is empty