Add PiCowbell CircuitPython I2C scan.
This commit is contained in:
parent
e194e43329
commit
e498983e54
1 changed files with 21 additions and 0 deletions
21
PiCowbell_Proto/i2c_scan/code.py
Normal file
21
PiCowbell_Proto/i2c_scan/code.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""CircuitPython I2C Device Address Scan for PiCowbell Proto and Pico"""
|
||||
import time
|
||||
import board
|
||||
|
||||
i2c = board.STEMMA_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()
|
||||
Loading…
Reference in a new issue