I'm trying to add a button to my
MCP23017 board. But my code is not working. What am i doing wrong?
import smbus import sys import getopt import time bus = smbus.SMBus(1) bus.write_byte_data(0x20,0x00,0xff) # input bus.write_byte_data(0x20,0x01,0xff) # input address = 0x20 # I2C address of MCP23017 # Handle the command line arguments def main(): while True: print(bus.read_byte_data(address, 0x12)) time.sleep(0.5) if __name__ == "__main__": main()
print is 0, even if i press the button