I bought a MCP23017 and doing some small test with it. I've made a simple Python script to make read_out of pin state. Can anyove explain to me, why i'm loosing a bit when GPIO_A7 is triggered? I've got 8 bit readout and all input changers state from 1 to 0 except GPIO_A7 so it looks like this:
GPIO_A0 = 11111110, GPIO_A1 = 11111101 But when hitting GPIO_A7 = 1111111
So i've only get 7 bit and not 8?
Hope for some help. :-)
#!/usr/bin/env python # # Input / output MCP23017 import smbus import sys import time bus = smbus.SMBus(1) once = False def start_up(once): if once != True: bus.write_byte_data(0x22, 0x00, 0xFF) # set input bank a time.sleep(0.1) bus.write_byte_data(0x22, 0x01, 0xFF) # set input bank b time.sleep(0.1) bus.write_byte_data(0x22, 0x0C, 0xFF) # set pull-up resistor time.sleep(0.1) bus.write_byte_data(0x22, 0x0D, 0xFF) # set pull-up resister time.sleep(0.1) once = True return once def read_data(bank): if bank == 0: state = bus.read_byte_data(0x22, 0x12) time.sleep(0.5) return state def main(): start_up(once) while True: state = read_data(0) print bin(state) if __name__ == "__main__": main()