Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PROGRAM KC868 A16 DI, DO AND LIQUID CRYSTAL FROM ARDUINO IDE
#11
(01-31-2025, 11:53 PM)admin Wrote: after china new year holidays, will test it then feedback to you.

I think that's great. Happy New Year and I appreciate your kind attention. Best regards.
Reply
#12
(01-27-2025, 05:43 PM)Cesarcardca Wrote: I NEED PROGRAM KC868 A16 DI, DO AND LIQUID CRYSTAL I2C FROM ARDUINO IDE. Or if your recommendation is through esphome, I could also try it, I need the syntax, or the devices for inputs and outputs so I can manipulate my program since I also need to interrupt a sensor.

Just add this code to your code for input/output controls.

Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// I2C address of the LCD
#define LCD_ADDR 0x3f
//Some models may use 0x27 address
// Initialize the LCD
LiquidCrystal_I2C lcd(LCD_ADDR, 20, 20);
void setup() {
  Wire.begin(4, 5);  // SDA pin = 4, SCL pin = 5 on the ESP32
  Serial.begin(115200);
 
  lcd.init();       // Initialize the LCD
  lcd.backlight();  // Turn on the LCD backlight
  lcd.setCursor(0, 0);
  lcd.print("LCD example");
}
void loop() {
  // Update the LCD content
  lcd.setCursor(0, 1); // Second line
  lcd.print(millis() / 1000); // Display the elapsed time in seconds
  delay(1000);
}

If you don't know the address of your display's I2C adapter, try finding it with the code below. Most use address 0x3F or 0x27.

Code:
#include <Wire.h>

void setup() {
  Wire.begin(4, 5); // Initialize I2C
  Serial.begin(115200);
  while (!Serial); // Wait for the serial monitor to initialize
  Serial.println("\nI2C Scanner");
}

void loop() {
  byte error, address;
  int nDevices = 0;

  Serial.println("Scanning...");

  for (address = 1; address < 127; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0) {
      Serial.print("Device found at address 0x");
      if (address < 16)
        Serial.print("0");
      Serial.print(address, HEX);
      Serial.println(" !");
      nDevices++;
    }
    else if (error == 4) {
      Serial.print("Unknown error at address 0x");
      if (address < 16)
        Serial.print("0");
      Serial.println(address, HEX);
    }
  }
 
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("Scan complete\n");

  delay(5000); // Wait 5 seconds before scanning again
}
Reply
#13
(01-31-2025, 05:50 PM)Cesarcardca Wrote:
(01-31-2025, 07:42 AM)admin Wrote: because you have not define the i2c bus SDA and SCL pin for ESP32.

these instructions are supposed to be for that. i got it from the Di and DO example on the forum. 
PCF8574 pcf8574_1 (0x22, 4, 5) and 
PCF8574 pcf8574_2(0x21, 4, 5) is for inputs. right?
is that what you mean?

do you have tested with our demo source code? https://www.kincony.com/forum/showthread.php?tid=1620
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)