Adsense HTML/JavaScript

Friday, September 11, 2020

pyboard MicroPython exercise: scan I2C address

 It's a MicroPython exercise running on pyboard, to scan I2C address of attached I2C device. Actually, the I2C device used is a OLED with I2C interface ssd1306 in next exercise.

i2c_scan.py

#I2C SCL connected to pyboard X12
#I2C SDA connected to pyboard X11

import machine
i2c_scl = machine.Pin('X12', machine.Pin.OUT_PP)
i2c_sda = machine.Pin('X11', machine.Pin.OUT_PP)

i2c = machine.I2C(scl=i2c_scl, sda=i2c_sda)
print(i2c.scan())


No comments:

Post a Comment