Some other issues I ran into was that when I did mcp0.config(7, OUTPUT) the code said that OUTPUT was not defined. So I used the 0 instead. The other thing that happens is when I try to use the mcp1.config(8, INPUT) I get input not defined. When I try mcp1.config(8, 1) I get the error pin 8 not set to input. So I used the pullup function and that seemed to not generate any errors but it also doesn't seem to work properly.
thanks for any help or advice. this is not production code. I am just trying to get my feet wet with how to use the code.
Brad
- Code: Select all
#!/usr/bin/python
from Adafruit_MCP230xx import Adafruit_MCP230XX
mcp0 = Adafruit_MCP230XX(busnum = 0, address = 0x20, num_gpios = 16)
mcp1 = Adafruit_MCP230XX(busnum = 0, address = 0x21, num_gpios = 16)
mcp0.config(7, 0)
mcp0.config(6, 0)
mcp0.config(5, 0)
mcp1.pullup(8,0)
mcp1.pullup(9,0)
mcp1.pullup(10,0)
print mcp1.input(8)
print mcp1.input(9)
print mcp1.input(10)
while (True):
if mcp1.input(8) == 1:
mcp0.output(7, 0)
mcp0.output(6, 1)
mcp0.output(5, 0)
elif mcp1.input(9) == 1:
mcp0.output(7, 0)
mcp0.output(6, 1)
mcp0.output(5, 0)
else:
mcp0.output(7, 0)
mcp0.output(6, 0)
mcp0.output(5, 0)