Smart Home Automation Forum
[Arduino source code for KC868-1U]-06_OUTPUT - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-1U (https://www.kincony.com/forum/forumdisplay.php?fid=52)
+--- Thread: [Arduino source code for KC868-1U]-06_OUTPUT (/showthread.php?tid=3009)



[Arduino source code for KC868-1U]-06_OUTPUT - KinCony Support - 06-21-2023

[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);
  }
 
}