PCA9555
This chapter will set up your port expander as an input device. If you're using at as an output device, you'll find the documentation here.
Adding the necessary code for PCA9555 requires two steps:
Setup
Run
Setup
The setup is done in 2_Board.ino. Set up your I2C channels, then scroll down to this section:
USING_PCA0555 is to disable/enable support for this IC. Set it to 1 to enable.
PCA9555_I2C_NUMBER lets to chose between I2C channel 0 or 1 on a RP2040 board. If you're not using a RP2040 board, just leave this at 0.
PCA9555interruptPins is an array where you put in the pin numbers for the pins used for interrupt. If you have several PCA9555 chips, list all the pins here.
PCA9995_OUTPUT is to set up the port expander as an output device. We're not going to use this if you're using it for switches.
Example: We have two PCA9555 using interrupt pins 10 and 16:
Run
You'll need to get the processor to read your PCA9555 and put the input values into the switch table. This is done with a simple function that you place in 30_Switches.ino
together with all your button functions. I recommend placing it at the very top, before anything else.
PCA9555Run()
The function wants to know a couple of things:
address: The I2C address of this PCA9555 chip.
interruptPin: The pin number of the interrupt pin used for this chip.
row: The row at which this port expander will start placing its input data. It will use the first 8 columns on this row, and the first 8 columns on the next row. Example: setting row to "4" means you'll find the expanders inputs on address 4,1 - 4,8 and 5,1 - 5,8 in the switch table.
Now, lets set up the two PCA955 in the example at the top of the page, and use rows 1 to 4 for these. We've wired 8 push buttons and 4 PEC11 encoders to each of them:
Last updated