openmv/scripts/examples/50-Arduino-Boards/Portenta-H7/50-Board-Control/i2c_control.py
iabdalkader 98a29e0870 scripts/examples: Update examples.
- Add examples index.
- Remove RP2040's Bluetooth examples.
- Resort examples.
2023-10-29 21:21:55 +01:00

25 lines
787 B
Python

# This work is licensed under the MIT license.
# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# I2C Control
#
# This example shows how to use the i2c bus on your OpenMV Cam by dumping the
# contents on a standard EEPROM. To run this example either connect the
# Thermopile Shield to your OpenMV Cam or an I2C EEPROM to your OpenMV Cam.
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("]")