@@ -41,14 +41,13 @@ class Adafruit_MCP230XX(object):
41
41
INPUT = 1
42
42
43
43
44
- def __init__ (self , busnum , address , num_gpios ):
44
+ def __init__ (self , address , num_gpios ):
45
45
assert num_gpios >= 0 and num_gpios <= 16 , "Number of GPIOs must be between 0 and 16"
46
- self .i2c = Adafruit_I2C (address , smbus . SMBus ( busnum ) )
46
+ self .i2c = Adafruit_I2C (address )
47
47
self .address = address
48
48
self .num_gpios = num_gpios
49
49
50
50
# set defaults
51
-
52
51
if num_gpios <= 8 :
53
52
self .i2c .write8 (MCP23008_IODIRA , 0xFF ) # all inputs on port A
54
53
self .direction = self .i2c .readU8 (MCP23008_IODIRA )
@@ -152,15 +151,12 @@ def pullup(self, pin, value):
152
151
153
152
154
153
if __name__ == '__main__' :
155
- # Use busnum = 0 for older Raspberry Pi's (pre 512MB)
156
- mcp = Adafruit_MCP230XX (busnum = 0 , address = 0x20 , num_gpios = 16 )
157
- # Use busnum = 1 for new Raspberry Pi's (512MB)
158
- # mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 16)
154
+ mcp = Adafruit_MCP230XX (address = 0x20 , num_gpios = 16 )
159
155
160
156
# Set pins 0, 1 and 2 to output (you can set pins 0..15 this way)
161
- mcp .config (0 , OUTPUT )
162
- mcp .config (1 , OUTPUT )
163
- mcp .config (2 , OUTPUT )
157
+ mcp .config (0 , mcp . OUTPUT )
158
+ mcp .config (1 , mcp . OUTPUT )
159
+ mcp .config (2 , mcp . OUTPUT )
164
160
165
161
# Set pin 3 to input with the pullup resistor enabled
166
162
mcp .pullup (3 , 1 )
0 commit comments