Skip to content

Commit fe80b0e

Browse files
authored
Merge branch 'master' into rockpaperscissors
2 parents 8e8b2f9 + 92119d5 commit fe80b0e

File tree

9 files changed

+25890
-5
lines changed

9 files changed

+25890
-5
lines changed
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
# 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()
27

38
import time
4-
59
import board
610

711
i2c = board.I2C()
812

913
while not i2c.try_lock():
1014
pass
1115

12-
while True:
13-
print("I2C addresses found:", [hex(device_address)
14-
for device_address in i2c.scan()])
15-
time.sleep(2)
16+
try:
17+
while True:
18+
print("I2C addresses found:", [hex(device_address)
19+
for device_address in i2c.scan()])
20+
time.sleep(2)
21+
22+
finally: # unlock the i2c bus when ctrl-c'ing out of the loop
23+
i2c.unlock()

0 commit comments

Comments
 (0)