Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import board
- import busio
- # Initialize and lock the I2C bus.
- i2c = busio.I2C(board.SCL, board.SDA)
- while not i2c.try_lock():
- pass
- # Mimick the DCFURS badge code
- try:
- i2c.writeto(0x44, bytes([0x15]), stop=False)
- result = bytearray(5)
- i2c.readfrom_into(0x44, result)
- print(result)
- except OSError:
- print('Unknown error')
- # Unlock the I2C bus when finished. Ideally put this in a try-finally!
- i2c.unlock()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement