例程讲解-02-i2c_control i2c控制
# I2C 控制
#
# 这个例子真是了如何使用i2c总线在标准的EEPROM上转换数据,为了运行这个例子,
# 你需要插入Thermopile扩展板。
from pyb import I2C
i2c = I2C(2, I2C.MASTER) # The i2c bus must always be 2.
mem = i2c.mem_read(256, 0x50, 0) # The eeprom slave address is 0x50.
print("\n[")
for i in range(16):
print("\t[", end='')
for j in range(16):
print("%03d" % mem[(i*16)+j], end='')
if j != 15: print(", ", end='')
print("]," if i != 15 else "]")
print("]")