Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Arduino IDE demo source code for KC868-A16]--#08-PCF8574-DO
#8
I've got a16 board and downloaded latest arduino IDE with esp board support rev 3.0.5. The difference is that pinout is a bit modified e.g. SDA/SDL are 21 & 22 not 4 & 5. Should use older version e.g. rev. 2.0.16? Also there is no definition of P0..P7, I made modification od example code as follow to get it compiled:
Code:
#include "Arduino.h"
#include "Adafruit_PCF8574.h"

static const uint8_t P0 = 0;
static const uint8_t P1 = 1;
static const uint8_t P2 = 2;
static const uint8_t P3 = 3;
static const uint8_t P4 = 4;
static const uint8_t P5 = 5;
static const uint8_t P6 = 6;
static const uint8_t P7 = 7;

// Set i2c address
Adafruit_PCF8574 pcf8574_1;//(0x24,4,5);
Adafruit_PCF8574 pcf8574_2;//(0x25,4,5);

void setup()
{
  Serial.begin(115200);

  pcf8574_1.pinMode(P0, OUTPUT);
  pcf8574_1.pinMode(P1, OUTPUT);
  pcf8574_1.pinMode(P2, OUTPUT);
  pcf8574_1.pinMode(P3, OUTPUT);
  pcf8574_1.pinMode(P4, OUTPUT);
  pcf8574_1.pinMode(P5, OUTPUT);
  pcf8574_1.pinMode(P6, OUTPUT);
  pcf8574_1.pinMode(P7, OUTPUT);

  pcf8574_2.pinMode(P0, OUTPUT);
  pcf8574_2.pinMode(P1, OUTPUT);
  pcf8574_2.pinMode(P2, OUTPUT);
  pcf8574_2.pinMode(P3, OUTPUT);
  pcf8574_2.pinMode(P4, OUTPUT);
  pcf8574_2.pinMode(P5, OUTPUT);
  pcf8574_2.pinMode(P6, OUTPUT);
  pcf8574_2.pinMode(P7, OUTPUT);

  Wire.begin(21, 22);

    Serial.print("Init pcf8574_1...");
    if (pcf8574_1.begin(0x24, &Wire)){
        Serial.println("PCF8574_1_OK");
    }else{
        Serial.println("PCF8574_1_KO");
    }

  Serial.print("Init pcf8574_2...");
  if (pcf8574_2.begin(0x25, &Wire)){
    Serial.println("PCF8574_2_OK");
  }else{
    Serial.println("PCF8574_2_KO");
  }


}

void loop()
{
  pcf8574_1.digitalWrite(P7, LOW);
  delay(1000);
  pcf8574_1.digitalWrite(P7, HIGH);
  delay(1000);

  pcf8574_2.digitalWrite(P7, LOW);
  delay(1000);
  pcf8574_2.digitalWrite(P7, HIGH);
  delay(1000);
}
Reply


Messages In This Thread
RE: [Arduino IDE demo source code for KC868-A16]--#08-PCF8574-DO - by shell - 11-07-2024, 08:36 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)