// PicoI2Cscanner.ino
//
// This sketch is for:
//   https://forum.arduino.cc/t/connect-a-arduino-pro-micro-with-a-raspberry-pi-pico/949404/
//
// Version 1, 20 January 2022, by Koepel, Public Domain
//
// Using the common I2C scanner.
//
// Raspberry Pi Pico in Arduino mode (on top of Mbed).
// SDA = GP6
// SCL = GP7
//
// Notes: 
//   In Real Life, there must be a I2C level shifter for a 5V LCD display.
//   The Wokwi simulation uses Serial1 at this moment.
// 


#include <Wire.h> //include Wire.h library

void setup()
{
  Serial1.begin( 115200);
  while( !Serial1) 
  {
    delay( 10); // wait for serial port to connect. Needed for native USB
  }
  Serial1.println( "I2C Scanner");

  Wire.begin();
}

void loop()
{
  byte error, address;
  int nDevices;

  Serial1.println( "Scanning...");

  nDevices = 0;
  for( address = 1; address < 127; address++ )
  {
    Wire.beginTransmission( address);
    error = Wire.endTransmission();

    if( error == 0)
    {
      Serial1.print( "  I2C device found at address 0x");
      if( address < 16)
        Serial1.print( "0");
      Serial1.println( address, HEX);
      nDevices++;
    }
  }
  if( nDevices == 0)
    Serial1.println( "No I2C devices found\n");
  else
    Serial1.println( "done\n");

  delay( 5000);
}
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
GND5VSDASCLSQWRTCDS1307+