Hi all, (long time reader, first time poster)
I'm trying to do some testing using GPIO expanders for input (as opposed to output as I've done for LCD / 7 segs). Every schematic I find online to try and use the PCF IC for input shows that the pin input should be directly pulled high to Vdd (through a button, switch or otherwise).
When testing this out, I notice the current consumption is pretty significant, rising by about 45mA on my supply. Inserting any medium-size resistance to try and limit current flow stops the PCF from reading the input and responding to it.
I'm really struggling to find the correct way to read - while I could continue using this sort of setup the project I'm planning for will use Power over USB and is limited to 0.5A in practice.
More details about my setup:
- ATMega324pa 40 PDIP, 20MHz XTAL
- Reading Decoded I2C bus on Scope with Decoder
- PCF8574a, address 0x39 (A0,A1!,A2!)
I can provide a few sketches and my code, but they won't be of much more use as I know the I2C bus and supply readings show the chip is working normally and my test LED is working fine. Below is the schematic I have been working off of:
many thanks!!
edit: I have decided to show off my code just in case I'm screwing up without noticing:
#include <Wire.h>
#include <PCF8574.h>
PCF8574 pcf(0x39);
const byte AVRLED = 24;
const byte PCFLEDpin = 0;
void setup() {
// put your setup code here, to run once:
pinMode(AVRLED, OUTPUT);
digitalWrite(AVRLED,HIGH);
pcf.begin(0);
pcf.setButtonMask(0xF0);
pcf.write(0,LOW);
}
void loop() {
// put your main code here, to run repeatedly:
if(pcf.read(7))
{
pcf.write(0,HIGH);
digitalWrite(AVRLED,HIGH);
}
else
{
pcf.write(0,LOW);
digitalWrite(AVRLED,LOW);
}
delay(50);
}