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 26486af commit 9b9afffCopy full SHA for 9b9afff
CircuitPython_Essentials/CircuitPython_I2C_Scan.py
@@ -1,15 +1,24 @@
1
# CircuitPython demo - I2C scan
2
+#
3
+# If you run this and it seems to hang, try manually unlocking
4
+# your I2C bus from the REPL with
5
+# ` >>> import board `
6
+# ` >>> board.I2C().unlock() `
7
8
import time
-
9
import board
10
11
i2c = board.I2C()
12
13
while not i2c.try_lock():
14
pass
15
16
+try:
17
+
18
while True:
19
print("I2C addresses found:", [hex(device_address)
20
for device_address in i2c.scan()])
21
time.sleep(2)
22
23
+finally: # unlock the i2c bus when ctrl-c'ing out of the loop
24
+ i2c.unlock()
0 commit comments