Skip to content

Commit cfafe15

Browse files
author
K. Townsend
committed
Added note about selecting I2C bus
1 parent f29fbbc commit cfafe15

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Adafruit_MCP230xx/Adafruit_MCP230xx.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
class Adafruit_MCP230XX(object):
4040
OUTPUT = 0
4141
INPUT = 1
42-
43-
def __init__(self, address, num_gpios):
44-
assert num_gpios >= 0 and num_gpios <= 16, "Number of GPIOs must be between 0 and 16"
45-
self.i2c = Adafruit_I2C(address=address)
42+
43+
def __init__(self, address, num_gpios, busnum = 0):
44+
assert num_gpios >= 0 and num_gpios <= 16, "Number of GPIOs must be between 0 and 16"
45+
self.i2c = Adafruit_I2C(address=address, bus=smbus.SMBus(busnum))
4646
self.address = address
4747
self.num_gpios = num_gpios
4848

@@ -182,6 +182,8 @@ def pullup(self, pin, value):
182182

183183
# ***************************************************
184184
# Set num_gpios to 8 for MCP23008 or 16 for MCP23017!
185+
# If you have a new Pi you may also need to add:
186+
# busnum = 1
185187
# ***************************************************
186188

187189
# Set pins 0, 1 and 2 to output (you can set pins 0..15 this way)

0 commit comments

Comments
 (0)