Python Library for Microchip MCP23018 16-bit I/O Expander with Open-Drain Outputs
Boards: USB I2C Click
Libraries:
- hidapi
pip install hidapi
- blinka
pip install adafruit-blinka
Note: click here for instructions how to setup your environment to use the USB I2C Click with circuitpython
This library is work in progress
The test.py file contains example code which has been tested on windows 10
To use library, instantiate MCP23018 as follows
mcp23018 = MCP23018(RESET_Pin = pin, I2C_Interface=I2C)
- Reset Device
mcp23018.reset()
- Wait x seconds
mcp23018.wait(x)
Debugging on all modules are by default switched off
- Switch External RESET_PIN debugging on
mcp23018.RESET.debug = True
- Switch External I2C Interface debugging on
mcp23018.I2C = True
- Switch Configuration Module debugging on
mcp23018.Configuration.debug = True
- Switch specific GPIO PIN debugging on
mcp23018.GPIO.port[PORT.B].pin[PIN.GP5].debug = True
- Set Configuration Parameter
mcp23018.Configuration.bank = PARAMETERS[PARAMETER.BANK].SEPARATE
- Get Configuration Parameter
configuration = mcp23018.Configuration.bank
- Set all GPIO Pins value
mcp23018.GPIO.value = STATE.LOW
- Get all GPIO Pins value
state = mcp23018.GPIO.value
- Set all GPIO Pins direction
mcp23018.GPIO.direction = DIRECTION.OUT
- Get all GPIO Pins direction
direction = mcp23018.GPIO.direction
- Set specific PORT GPIO Pins value
mcp23018.GPIO.port[PORT.A].value = STATE.LOW
- Get specific PORT GPIO Pins value
state = mcp23018.GPIO.port[PORT.A].value
- Set specific PORT GPIO Pins direction
mcp23018.GPIO.port[PORT.A].direction = DIRECTION.OUT
- Get specific PORT GPIO Pins direction
mcp23018.GPIO.port[PORT.A].direction = DIRECTION.OUT
- Set specific GPIO Pins value
mcp23018.GPIO.port[PORT.A].pin[PIN.GP0].value = STATE.LOW
- Get specific GPIO Pins value
state = mcp23018.GPIO.port[PORT.A].pin[PIN.GP0].value
- Set specific GPIO Pins direction
mcp23018.GPIO.port[PORT.A].pin[PIN.GP0].direction = DIRECTION.OUT
- Get specific GPIO Pins direction
direction = mcp23018.GPIO.port[PORT.A].pin[PIN.GP0].direction