Code: Select all
""" (based on) I2C rotary encoder simple test example."""
import board
from adafruit_seesaw import seesaw, rotaryio, digitalio
print("hello test!")
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
print("- I2C scan -----------")
i2c.try_lock()
print(f"{i2c.scan()}")
print("----------------------")
i2c.unlock()
seesaw = seesaw.Seesaw(i2c, addr=0x36)
seesaw_product = (seesaw.get_version() >> 16) & 0xFFFF
print("Found product {}".format(seesaw_product))
if seesaw_product != 4991:
print("Wrong firmware loaded? Expected 4991")
else:
print("Found correct device code!")
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
main.py output:
hello test!
- I2C scan -----------
[41, 54, 57]
----------------------
Found product 4991
Found correct device code!
Why does this work? I've attached the devices to the STEMMA connector, not directly to the pins labeled SCL/SDA. Isn't that what the code is supposed to do? I am so confused. :-) Please enlighten me.
/rob