adafruit_mcp230xx

CircuitPython module for the MCP23017 and MCP23008 I2C I/O extenders.

  • Author(s): Tony DiCola
class adafruit_mcp230xx.DigitalInOut(pin_number, mcp230xx)

Digital input/output of the MCP230xx. The interface is exactly the same as the digitalio.DigitalInOut class (however the MCP230xx does not support pull-down resistors and an exception will be thrown attempting to set one).

direction

The direction of the pin, either True for an input or False for an output.

pull

Enable or disable internal pull-up resistors for this pin. A value of digitalio.Pull.UP will enable a pull-up resistor, and None will disable it. Pull-down resistors are NOT supported!

switch_to_input(pull=None, **kwargs)

Switch the pin state to a digital input with the provided starting pull-up resistor state (optional, no pull-up by default). Note that pull-down resistors are NOT supported!

switch_to_output(value=False, **kwargs)

Switch the pin state to a digital output with the provided starting value (True/False for high or low, default is False/low).

value

The value of the pin, either True for high or False for low. Note you must configure as an output or input appropriately before reading and writing this value.

class adafruit_mcp230xx.MCP23008(i2c, address=<sphinx.ext.autodoc.importer._MockObject object>)

Initialize MCP23008 instance on specified I2C bus and optionally at the specified I2C address.

get_pin(pin)

Convenience function to create an instance of the DigitalInOut class pointing at the specified pin of this MCP23008 device.

gpio

The raw GPIO output register. Each bit represents the output value of the associated pin (0 = low, 1 = high), assuming that pin has been configured as an output previously.

gppu

The raw GPPU pull-up register. Each bit represents if a pull-up is enabled on the specified pin (1 = pull-up enabled, 0 = pull-up disabled). Note pull-down resistors are NOT supported!

iodir

The raw IODIR direction register. Each bit represents direction of a pin, either 1 for an input or 0 for an output mode.

class adafruit_mcp230xx.MCP23017(i2c, address=<sphinx.ext.autodoc.importer._MockObject object>)

Initialize MCP23017 instance on specified I2C bus and optionally at the specified I2C address.

get_pin(pin)

Convenience function to create an instance of the DigitalInOut class pointing at the specified pin of this MCP23017 device.

gpio

The raw GPIO output register. Each bit represents the output value of the associated pin (0 = low, 1 = high), assuming that pin has been configured as an output previously.

gpioa

The raw GPIO A output register. Each bit represents the output value of the associated pin (0 = low, 1 = high), assuming that pin has been configured as an output previously.

gpiob

The raw GPIO B output register. Each bit represents the output value of the associated pin (0 = low, 1 = high), assuming that pin has been configured as an output previously.

gppu

The raw GPPU pull-up register. Each bit represents if a pull-up is enabled on the specified pin (1 = pull-up enabled, 0 = pull-up disabled). Note pull-down resistors are NOT supported!

gppua

The raw GPPU A pull-up register. Each bit represents if a pull-up is enabled on the specified pin (1 = pull-up enabled, 0 = pull-up disabled). Note pull-down resistors are NOT supported!

gppub

The raw GPPU B pull-up register. Each bit represents if a pull-up is enabled on the specified pin (1 = pull-up enabled, 0 = pull-up disabled). Note pull-down resistors are NOT supported!

iodir

The raw IODIR direction register. Each bit represents direction of a pin, either 1 for an input or 0 for an output mode.

iodira

The raw IODIR A direction register. Each bit represents direction of a pin, either 1 for an input or 0 for an output mode.

iodirb

The raw IODIR B direction register. Each bit represents direction of a pin, either 1 for an input or 0 for an output mode.