import machine
import time

sdaPIN=machine.Pin(13)
sclPIN=machine.Pin(14)
i2c=machine.I2C(0,sda=sdaPIN, scl=sclPIN, freq=400000)

# determine addresses of devices on i2c bus
devices = i2c.scan()
if len(devices) != 0:
    print('Number of I2C devices found=',len(devices))
    for device in devices:
        print("Device Hexadecimel Address= ",hex(device))
else:
    print("No device found")

# device at 0x20 is the line tracker
# read the output and convert to integer 0-7 and binary
for k in range(40):
    test1 = i2c.readfrom(0x20,1)
    test1 = test1[0] - 248
    bin1 = bin(test1)[2:]
    print(k,':  0x20:  ', test1, '   binary: ',bin1)
    time.sleep(1.5)