pcf.ino
1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#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);
}