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.
1 parent e194e43 commit e498983Copy full SHA for e498983
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