# Source from: https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221

"""CircuitPython Essentials I2C Scan example"""
# If you run this and it seems to hang, try manually unlocking
# your I2C bus from the REPL with
#  >>> import board
#  >>> board.I2C().unlock()

import time
import board

i2c = board.I2C()

while not i2c.try_lock():
    pass

try:
    while True:
        print("I2C addresses found:", [hex(device_address)
              for device_address in i2c.scan()])
        time.sleep(2)

finally:  # unlock the i2c bus when ctrl-c'ing out of the loop
    i2c.unlock()

# Source from: https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221

"""CircuitPython Essentials I2C Scan example"""
# If you run this and it seems to hang, try manually unlocking
# your I2C bus from the REPL with
#  >>> import board
#  >>> board.I2C().unlock()

import time
import board

i2c = board.I2C()

while not i2c.try_lock():
    pass

try:
    while True:
        print("I2C addresses found:", [hex(device_address)
              for device_address in i2c.scan()])
        time.sleep(2)

finally:  # unlock the i2c bus when ctrl-c'ing out of the loop
    i2c.unlock()

# Source from: https://learn.adafruit.com/circuitpython-libraries-on-any-computer-with-mcp2221 CircuitPython Essentials I2C Scan example # If you run this and it seems to hang, try manually unlocking # your I2C bus from the REPL with #  >>> import board #  >>> board.I2C().unlock() # unlock the i2c bus when ctrl-c'ing out of the loop