By dave | May 20, 2023

IO Abstraction library fully supports the MPR121 12-bit Touch control and IO expander chips on Arduino and mbed. It requires only two pins (three for interrupt mode) SDA, SCL, and optionally INT. Our driver integrates the Touch, GPIO, LED controller, and interrupt support providing nearly all functions using familiar Arduino terminology.

This device can even be used in conjunction with an MPR121 analog device to make it even easier to use the LED controller.


The MPR121 is a pretty complete device, and has most capabilities of Arduino pins, however there are several notes:

  • Interrupt support, you can enable interrupt handling but it affects all pins at once.
  • This device support three modes of input. Touch controller (see example), digital input, and digital input with pull up.
  • The first 4 pins are touch control only, the later 8 are GPIO. These are mapped sequentially from 0..11.
  • LED controller mode, it has a 15 step led controller, you can create an analog device that normalizes this to range 0..255 or as a float between 0 and 1.
  • Using touch is enabled from pin 0 to a given pin number, and if you enable more than 4 touch pins, we turn off the GPIO functions.
  • You can also get the raw touch values from the analog device by reading them, again between 0 and 255 or as a float.

See the example for more on how to use this device, it is more complex to set up than most other devices and better explained in the example.

Once you have created an instance, simply use it like any other IoAbstraction they all work the same way.

To find your i2c device address use this i2c address scanner, this sketch will tell you every address on which it finds an i2c chip.

Additional notes for LED controller mode

If you want to use the LED control function of the device, there is an additional output type, it is LED_CURRENT_OUTPUT. You can enable the LED mode two ways.

  1. on the device abstraction call ioAW9523.pinMode(pin, LED_CURRENT_OUTPUT);
  2. create the analog abstraction as per the example, and initialise the pin as PWM analogAw9523.initPin(pin, DIR_PWM);

See the reference docs linked above or example for more information.

Go back to the IoAbstraction page

Other pages within this category

This site uses cookies to analyse traffic, and to record consent. We also embed Twitter and Youtube content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.