01-05-2022, 07:08 AM
(This post was last modified: 05-07-2022, 03:13 AM by KinCony Support.)
Code 6: //The demo code is PCF8574-DO You can copy the code to your Arduino IDE
Code:
#include "Arduino.h"
#include "PCF8574.h"
// Set i2c address
PCF8574 pcf8574(0x24,4,5); // 0x24 is address IO4 is SDA IO5 is SCL
void setup()
{
Serial.begin(115200);
// delay(1000);
// Set pinMode to OUTPUT
pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P1, OUTPUT);
pcf8574.pinMode(P2, OUTPUT);
pcf8574.pinMode(P3, OUTPUT);
pcf8574.pinMode(P4, OUTPUT);
pcf8574.pinMode(P5, OUTPUT);
pcf8574.pinMode(P6, OUTPUT);
pcf8574.pinMode(P7, OUTPUT);
// pcf8574.pinMode(P1, INPUT);
Serial.print("Init pcf8574...");
if (pcf8574.begin()){
Serial.println("OK");
}else{
Serial.println("KO");
}
}
void loop()
{
pcf8574.digitalWrite(P0, HIGH);
delay(300);
pcf8574.digitalWrite(P0, LOW);
delay(300);
}