Hi,
I want to on the led when P6 pin HIGH and off the led when P6 pin LOW. But the LED doesn't on or off in any condition. Here is my code.
#define ARDUINO_H
#include <PCF8574.h>
//set i2c address
PCF8574 pcf8574_1(0x20);//create an instance of a PCF8574 object at 0x20 address
int OutPins[] = {13, 12};
int s;//Array element's parameter of OutPins[] array
void setup() {
Serial.begin(9600);
//set pinMode to INPUT
pcf8574_1.pinMode(P0, INPUT);
pcf8574_1.pinMode(P1, INPUT);
pcf8574_1.pinMode(P2, INPUT);
pcf8574_1.pinMode(P3, INPUT);
pcf8574_1.pinMode(P4, INPUT);
pcf8574_1.pinMode(P5, INPUT);
pcf8574_1.pinMode(P6, INPUT);
pcf8574_1.pinMode(P7, INPUT);
pcf8574_1.begin();
setupOutPins();//set the pinMode() function to LEDs
digitalWrite ( OutPins[0], 1);
}
void setupOutPins() {
for (s = 0; s < 2; s++) {
pinMode (OutPins[s], OUTPUT);
delayMicroseconds (100);
}
}
void loop() {
IncRead1 (); //Gives the output when the water level increasing in dip switch one
DecRead1();//Gives the output when the water level decreasing in dip switch one
}
void IncRead1() {
if(pcf8574_1.digitalRead(P0)==HIGH){
Serial.println("Inc water level 1");
}
if (pcf8574_1.digitalRead(P6) == HIGH) {
digitalWrite(OutPins[1], 1);
}
}
void DecRead1(){
if (pcf8574_1.digitalRead(P6) == LOW) {
digitalWrite(OutPins[1], 0);
}
}
Many thanks in advance.