We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e194e43 + e498983 commit 59ae4b1Copy full SHA for 59ae4b1
PiCowbell_Proto/i2c_scan/code.py
@@ -0,0 +1,21 @@
1
+# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
2
+# SPDX-License-Identifier: MIT
3
+"""CircuitPython I2C Device Address Scan for PiCowbell Proto and Pico"""
4
+import time
5
+import board
6
+
7
+i2c = board.STEMMA_I2C()
8
9
+while not i2c.try_lock():
10
+ pass
11
12
+try:
13
+ while True:
14
+ print(
15
+ "I2C addresses found:",
16
+ [hex(device_address) for device_address in i2c.scan()],
17
+ )
18
+ time.sleep(2)
19
20
+finally: # unlock the i2c bus when ctrl-c'ing out of the loop
21
+ i2c.unlock()
0 commit comments