pcf.ino 1005 Bytes
#include "pcf.h"

void updateButton(struct button *buttonX) {
  int read = 0; //!pcf8574.digitalRead(buttonX->pin);
  buttonX->pressed = ( buttonX->holding == 0 && read == 1 ) ? (1) : (0);
  buttonX->released = ( buttonX->holding == 1 && read == 0 ) ? (1) : (0);
  buttonX->holding = read;
}

void setup_pcf () {
  pcf8574.pinMode(PINbutton1, INPUT);
  pcf8574.pinMode(PINbutton2, INPUT);
  pcf8574.pinMode(PINbutton3, INPUT);
  pcf8574.pinMode(led, OUTPUT);
  pcf8574.pinMode(leeren11, OUTPUT);
  pcf8574.pinMode(leeren1, OUTPUT);
  pcf8574.pinMode(leeren2, OUTPUT);
  pcf8574.pinMode(fuellen2, OUTPUT);
  pcf8574.begin();

  button1->pin = 1;
  button1->holding = 0;
  button1->pressed = 0;
  button1->released = 0;

  button2->pin = 2;
  button2->holding = 0;
  button2->pressed = 0;
  button2->released = 0;

  button3->pin = 3;
  button3->holding = 0;
  button3->pressed = 0;
  button3->released = 0;
}

void loop_pcf () {
  updateButton(button1);
  updateButton(button2);
  updateButton(button3);
}