Skip to content

Commit 46dcd23

Browse files
update PCF8574 init
1 parent c166be1 commit 46dcd23

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

MultiPlexer_PCF8574/MultiPlexer_PCF8574.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@ MultiPlexer_PCF8574::MultiPlexer_PCF8574(uint8_t address) {
99
}
1010

1111
void MultiPlexer_PCF8574::begin() {
12-
for (int i=0; i<8; i++) {
12+
Serial.print("Initializing PCF8574... ");
13+
// inputs
14+
int i = 0;
15+
for (i = 0; i<4; i++) {
1316
_expander->pinMode(i, INPUT);
1417
}
18+
// outputs
19+
for (i=4; i<8; i++) {
20+
_expander->pinMode(i, OUTPUT, LOW);
21+
}
1522

16-
if (_expander->begin()) {
17-
Serial.println("OK");
18-
} else{
19-
Serial.println("KO");
20-
}
23+
if (_expander->begin()) {
24+
Serial.println("OK");
25+
} else{
26+
Serial.println("Error!");
27+
}
2128
}
2229

2330
void MultiPlexer_PCF8574::loop() {

0 commit comments

Comments
 (0)