06-21-2023, 05:22 AM
(This post was last modified: 06-21-2023, 05:38 AM by KinCony Support.)
[Arduino source code for KC868-1U]-06_OUTPUT
Code:
/*KC868-1U PCF8574 digital output code*/
#include "Arduino.h"
#include "PCF8574.h"
// Set i2c address
PCF8574 pcf8574_OUT1(0x24,4,16);
void setup()
{
Serial.begin(115200);
// delay(1000);
// Set pinMode to OUTPUT
pcf8574_OUT1.pinMode(P0, OUTPUT);
pcf8574_OUT1.pinMode(P1, OUTPUT);
pcf8574_OUT1.pinMode(P2, OUTPUT);
pcf8574_OUT1.pinMode(P3, OUTPUT);
pcf8574_OUT1.pinMode(P4, OUTPUT);
pcf8574_OUT1.pinMode(P5, OUTPUT);
pcf8574_OUT1.pinMode(P6, OUTPUT);
pcf8574_OUT1.pinMode(P7, OUTPUT);
pcf8574_OUT1.begin();
}
void loop()
{
for(int i=0;i<=7;i++){
pcf8574_OUT1.digitalWrite(i, LOW);
delay(1000);
}
for(int i=0;i<=7;i++){
pcf8574_OUT1.digitalWrite(i, HIGH);
delay(1000);
}
}