I have a circuit which uses a PCF8574 I2C to Parallel converter. Is use this for a keypad. I try to build this in SimulIDE
I use the I2C-to-Parallel component
I connect D0-D3 to the rows of my Keypad
I connect D4-D6 to the columns of my keypad
I configure the Control Code to be 32 (=0x20), the default address for PCF8574
A0-A2 are tied to ground.
Now I setup the device by writing 0xF0, making my rows logically 0. As per PCF8574, lines programmed HIGH are inputs (floating).
Because this device does not have an interrupt output, I created one using diode-logic, tying the cathode of 3 diodes each to one of the column lines, and the anodes to the interrupt pin of the Arduino (using a pullup resistor).
When I start the module (I use the PCF8574 library by Rob Tillaart because it is low level and very straightforward), I can see the rows being low, and the columns being high (animation is on). The interrupt is also high.
When I push a key on the keypad, the corresponding column goes low. This triggers an interrupt
So far, so good.
In my interrupt routine, I read the output of the PCF8574. I would expect all rows low, and two columns high and one low (the column with the pressed key).
However, I always get the value '0', but I would expect 96, 140 or 192 (the values with exactly 2 bits high).
When I search this site for info about the I2C-to-Parallel converter, something is mentioned about reading and writing to different addresses.
I do not quite understand that explanation; why would you be reading back from a different address (= a different device)?
When I upload my code to real hardware with a PCF8574, it works as expected.
The question is, how do I use the I2C-to-Parallel converter to emulate a PCF8574? It appears that writing is working okay, but reading back is somehow wrong.
Looking forward to any reply. Pointers to more info are also very welcome!