Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Arduino IDE demo source code for KC868-A8]--#07-PCF8574-DO
#1
Star 
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);
}
   
   
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)