Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,123
» Latest member: victordaniel
» Forum threads: 2,792
» Forum posts: 14,674

Full Statistics

Online Users
There are currently 89 online users.
» 4 Member(s) | 55 Guest(s)
Amazonbot, Bing, Bytespider, Crawl, Google, PetalBot, Semrush, SkypeUriPreview, XenForo/, Yandex, bot, johnidicula, peacemakerv, sserb, victordaniel

Latest Threads
Several controllers in on...
Forum: KC868-A6
Last Post: admin
17 minutes ago
» Replies: 3
» Views: 11
Water supply automation
Forum: Getting Started with ESPHome and Home Assistant
Last Post: admin
20 minutes ago
» Replies: 1
» Views: 1
"KCS" v2.2.10 firmware BI...
Forum: "KCS" v2 firmware system
Last Post: draugen
5 hours ago
» Replies: 25
» Views: 2,215
Kc868-a32 spi
Forum: KC868-A32/A32 Pro
Last Post: admin
7 hours ago
» Replies: 1
» Views: 7
PROGRAM KC868 A16 DI, DO ...
Forum: KC868-A16
Last Post: admin
7 hours ago
» Replies: 18
» Views: 227
KinCony KC868-A6v3 ESP32-...
Forum: News
Last Post: admin
10 hours ago
» Replies: 0
» Views: 8
KC868, is there some API...
Forum: "KCS" v2 firmware system
Last Post: admin
11 hours ago
» Replies: 1
» Views: 6
Product suggestion: bus b...
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
11 hours ago
» Replies: 7
» Views: 153
http_request on ethernet
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
11 hours ago
» Replies: 3
» Views: 16
THT22 and 5v
Forum: Development
Last Post: admin
11 hours ago
» Replies: 15
» Views: 198

  [arduino code examples for A6v3]-11 SX1278 LoRA wireless receiver and transmitter
Posted by: admin - 01-15-2025, 03:21 AM - Forum: KC868-A6v3 - No Replies

SX1278  Transmitter:

Code:
#include <LoRa.h>
#include <SPI.h>

#define ss 38
#define rst 42
#define dio0 41

int counter = 0;

void setup()
{
  Serial.begin(115200);
  while (!Serial);
  Serial.println("LoRa Sender");

  LoRa.setPins(ss, rst, dio0);    //setup LoRa transceiver module
 
  while (!LoRa.begin(433E6))     //433E6 - Asia, 866E6 - Europe, 915E6 - North America
  {
    Serial.println(".");
    delay(500);
  }
  LoRa.setSyncWord(0xA5);
  Serial.println("LoRa Initializing OK!");
}

void loop()
{
  Serial.print("Sending packet: ");
  Serial.println(counter);

  LoRa.beginPacket();   //Send LoRa packet to receiver
  LoRa.print("hello ");
  LoRa.print(counter);
  LoRa.endPacket();

  counter++;

  delay(2000);
}

SX1278 Receiver:
Code:
#include <LoRa.h>
#include <SPI.h>

#define ss 38
#define rst 42
#define dio0 41

void setup()
{
  Serial.begin(115200);
  while (!Serial);
  Serial.println("LoRa Receiver");

  LoRa.setPins(ss, rst, dio0);    //setup LoRa transceiver module

  while (!LoRa.begin(433E6))     //433E6 - Asia, 866E6 - Europe, 915E6 - North America
  {
    Serial.println(".");
    delay(500);
  }
  LoRa.setSyncWord(0xA5);
  Serial.println("LoRa Initializing OK!");
}

void loop()
{
  int packetSize = LoRa.parsePacket();    // try to parse packet
  if (packetSize)
  {
   
    Serial.print("Received packet '");

    while (LoRa.available())              // read packet
    {
      String LoRaData = LoRa.readString();
      Serial.print(LoRaData);
    }
    Serial.print("' with RSSI ");         // print RSSI of packet
    Serial.println(LoRa.packetRssi());
  }
}

Print this item

  [arduino code examples for A6v3]-10 nRF24L01 wireless receiver and transmitter
Posted by: admin - 01-15-2025, 03:17 AM - Forum: KC868-A6v3 - No Replies

nRF24L01 Transmitter:

Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 40
#define CSN_PIN 38

const uint64_t abc = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN);
char data[] = "Hello World, KinCony";

void setup()
{
   Serial.begin(9600);
   radio.begin();
   radio.openWritingPipe(abc);
}

void loop()
{
   radio.write( data, sizeof(data) );
}

nRF24L01 Receiver:
Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 40
#define CSN_PIN 38

const uint64_t id = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN);

#define SIZE 32            // this is the maximum for this example. (minimum is 1)
char buffer[SIZE + 1];     // for the RX node
uint8_t counter = 0;       // for counting the number of received payloads

void setup()
{
   Serial.begin(9600);
   delay(1000);
   Serial.println("Nrf24L01 Receiver Starting");
   radio.begin();
   radio.openReadingPipe(1,id);
   radio.startListening();;
}

void loop()
{
    if (radio.available()) {         // is there a payload?
      radio.read(&buffer, SIZE);     // fetch payload from FIFO
      Serial.print("Received:");
      Serial.print(buffer);          // print the payload's value
      Serial.print(" - ");
      Serial.println(counter++);     // print the received counter
    }
}

Print this item

  [arduino code examples for A6v3]-09 Dimmer analog output by GP8403
Posted by: admin - 01-15-2025, 03:15 AM - Forum: KC868-A6v3 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* This Arduino program controls the GP8403 DAC I2C chip using an ESP32-S3 board.
* The program sets the DAC outputs for two channels:
* - Channel 0 (CH0) outputs 5V.
* - Channel 1 (CH1) outputs 10V.
*
* The I2C communication is handled using the Wire library, and the SDA and SCL pins
* are custom defined as GPIO12 (SDA) and GPIO11 (SCL).
*
* GP8403 I2C address: 0x58
*/

#include "DFRobot_GP8403.h"

// Initialize the GP8403 DAC object with the I2C address 0x58
DFRobot_GP8403 dac(&Wire, 0x58);

void setup() {
  // Start serial communication for debugging purposes
  Serial.begin(115200);

  // Initialize I2C communication with custom SDA and SCL pins
  Wire.begin(12, 11);  // SDA = GPIO12, SCL = GPIO11

  // Try to initialize the DAC, retry if initialization fails
  while(dac.begin() != 0) {
    Serial.println("Initialization failed, retrying...");
    delay(1000);  // Wait for 1 second before retrying
  }

  // If initialization succeeds
  Serial.println("Initialization successful!");

  // Set the DAC output range to 10V (this setting applies to both channels)
  dac.setDACOutRange(dac.eOutputRange10V);

  // Set the output for DAC channel 0 to 5V
  // Range for 10V mode is 0-10000, so 5000 represents 5V
  dac.setDACOutVoltage(5000, 0);  // Set CH0 to 5V
  Serial.println("Channel 0 set to 5V");

  // Set the output for DAC channel 1 to 10V
  dac.setDACOutVoltage(10000, 1);  // Set CH1 to 10V
  Serial.println("Channel 1 set to 10V");

  // Store the data in the chip's non-volatile memory so it persists after power-off
  dac.store();
  Serial.println("DAC values stored in memory");
}

void loop() {
  // No need to continuously write the values, the DAC holds the last set value
}
arduino ino file download:
.zip   dac-GP8403.zip (Size: 975 bytes / Downloads: 17)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   dac-GP8403.ino.merged.zip (Size: 189.99 KB / Downloads: 17)

Print this item

  [arduino code examples for A6v3]-08 Print TEXT on SSD1306 OLED displayer
Posted by: admin - 01-15-2025, 03:12 AM - Forum: KC868-A6v3 - No Replies

Code:
/*OLED SSD1306 Code for KC868-A6v3*/

#include <U8g2lib.h>
#include <Wire.h>

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,  11, 12, U8X8_PIN_NONE);//SCL IO11  SDA  IO12   

void page1() {
  u8g2.setFont(u8g2_font_timR18_tf);// Font 18
  u8g2.setFontPosTop();
  u8g2.setCursor(5,0);
  u8g2.print("KINCONY");
  u8g2.setFont(u8g2_font_timR12_tf);//Font 12
  u8g2.setCursor(0,40);
  u8g2.print("www.kincony.com");
}
void setup(){

  u8g2.setI2CAddress(0x3C*2);
  u8g2.begin();
  u8g2.enableUTF8Print();
}
void loop(){
  u8g2.firstPage();
  do
  {
    page1();
  }while(u8g2.nextPage());

}
arduino ino file download:
.zip   oled.zip (Size: 500 bytes / Downloads: 24)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   oled.ino.merged.zip (Size: 201.21 KB / Downloads: 27)

Print this item

  [arduino code examples for A6v3]-07 digital INPUT trigger OUTPUT directly
Posted by: admin - 01-15-2025, 03:10 AM - Forum: KC868-A6v3 - No Replies

Code:
/*
  PCF8574 I2C Digital I/O Expander Example
  Made by KinCony IoT: https://www.kincony.com

  Description:
  This program demonstrates how to use a PCF8574 I2C expander to read input pins and control relays.
  It reads input states from a PCF8574 module and controls corresponding relays.
 
  The program initializes the input pins as INPUT and output pins as OUTPUT.
  When an input is triggered (LOW), the corresponding relay (output) will activate (LOW).
  It also prevents the relays from briefly activating on startup.

  Custom I2C pins are defined for SDA and SCL.

  License:
  You are free to use and modify this code for personal or commercial purposes as long as this
  copyright notice remains intact.
*/

// Define custom I2C pins for communication
#define SDA_PIN 12    // Set SDA pin for I2C communication
#define SCL_PIN 11   // Set SCL pin for I2C communication

#include "Arduino.h"
#include "PCF8574.h"
#include <Wire.h>

// Define I2C addresses for the input and output PCF8574 modules
PCF8574 pcf8574_input(0x22);  // I2C address for the input expander (change according to your setup)
PCF8574 pcf8574_output(0x24); // I2C address for the output expander (change according to your setup)

void setup() {
  // Start serial communication for debugging purposes
  Serial.begin(115200);
  delay(1000);  // Wait for serial communication to initialize

  // Initialize I2C and set custom SDA and SCL pins
  Wire.begin(SDA_PIN, SCL_PIN);

  // Ensure all relay outputs are set to HIGH (deactivated) before initializing the expander
  // This step is to avoid any relay from briefly turning on during setup
  for (int i = 0; i < 6; i++) {
    pcf8574_output.digitalWrite(i, HIGH);
  }

  // Initialize input pins as INPUT
  pcf8574_input.pinMode(P0, INPUT);
  pcf8574_input.pinMode(P1, INPUT);
  pcf8574_input.pinMode(P2, INPUT);
  pcf8574_input.pinMode(P3, INPUT);
  pcf8574_input.pinMode(P4, INPUT);
  pcf8574_input.pinMode(P5, INPUT);

  // Initialize output pins as OUTPUT (these control the relays)
  pcf8574_output.pinMode(P0, OUTPUT);
  pcf8574_output.pinMode(P1, OUTPUT);
  pcf8574_output.pinMode(P2, OUTPUT);
  pcf8574_output.pinMode(P3, OUTPUT);
  pcf8574_output.pinMode(P4, OUTPUT);
  pcf8574_output.pinMode(P5, OUTPUT);

  // Ensure all outputs (relays) are deactivated at the start (set to HIGH)
  for (int i = 0; i < 6; i++) {
    pcf8574_output.digitalWrite(i, HIGH);
  }

  // Initialize the PCF8574 modules and check for errors
  Serial.print("Init pcf8574_input...");
  if (pcf8574_input.begin()) {
    Serial.println("OK");  // Input expander initialized successfully
  } else {
    Serial.println("KO");  // Input expander initialization failed
  }

  Serial.print("Init pcf8574_output...");
  if (pcf8574_output.begin()) {
    Serial.println("OK");  // Output expander initialized successfully
  } else {
    Serial.println("KO");  // Output expander initialization failed
  }
}

void loop() {
  // Read input states from the input expander (PCF8574)
  uint8_t val[6];  // Array to store input states
  for (int i = 0; i < 6; i++) {
    val[i] = pcf8574_input.digitalRead(i);  // Read the state of each input pin
  }

  // Control relays based on the input states
  for (int i = 0; i < 6; i++) {
    if (val[i] == LOW) {
      // If the input is LOW (triggered), activate the corresponding relay (set to LOW)
      pcf8574_output.digitalWrite(i, LOW);
    } else {
      // If the input is HIGH (not triggered), deactivate the corresponding relay (set to HIGH)
      pcf8574_output.digitalWrite(i, HIGH);
    }
  }

  delay(300);  // Small delay to prevent rapid state changes
}
arduino ino file download:
.zip   Input-trigger-Output.zip (Size: 1.35 KB / Downloads: 19)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   Input-trigger-Output.ino.merged.zip (Size: 191.31 KB / Downloads: 19)

Print this item

  [arduino code examples for A6v3]-06 how to DS3231 RTC clock
Posted by: admin - 01-15-2025, 03:08 AM - Forum: KC868-A6v3 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* DS3231 RTC with Arduino
*
* This program demonstrates how to use the DS3231 RTC (Real-Time Clock) module with the Arduino.
* It includes functionality to:
* - Initialize the DS3231 RTC module
* - Read the current date and time from the RTC
* - Set the RTC time based on a serial command:Command format: DYYYY-MM-DDTHH:MM:SS
*    Set date and time command example: D2024-09-19T11:50:22
*    print current date and time command: current time
*
*
* Hardware Connections:
* - SDA: GPIO 12
* - SCL: GPIO 11
*/

#include <DS3231.h>
#include <Wire.h>

String serial_cmd_rcv = ""; // Serial port receiver

typedef struct
{
  byte year;    // Last two digits of the year, library adds 2000.
  byte month;
  byte day;
  byte hour;
  byte minute;
  byte second;
} MY_DATE_STR;

MY_DATE_STR my_date_str = {0};

// Define constants for relay control
#define OPEN_RLY_DATA    26
#define OPEN_RLY_MONTH   4
#define CLOSE_RLY_DATA   2
#define CLOSE_RLY_MONTH  5

// Define pin connections
#define SDA_PIN   12
#define SCL_PIN   11

DS3231 rtc; // Create an instance of the DS3231 RTC
bool h12Flag;
bool pmFlag;
static bool bCentury = false;
static bool old_level_high = false;
static bool old_level_low = false;


/**
* @brief Print the current time from the RTC to the Serial Monitor.
*/
static void PrintfCurTime()
{
  Serial.print("Current time is: ");
  int year = rtc.getYear() + 2000;
  Serial.print(year);
  Serial.print("-");

  Serial.print(rtc.getMonth(bCentury), DEC);
  Serial.print("-");

  Serial.print(rtc.getDate(), DEC);
  Serial.print(" ");

  Serial.print(rtc.getHour(h12Flag, pmFlag), DEC);
  Serial.print(":");
  Serial.print(rtc.getMinute(), DEC);
  Serial.print(":");
  Serial.println(rtc.getSecond(), DEC);
}

/**
* @brief Process serial commands to set the RTC time.
* Command format: DYYYY-MM-DDTHH:MM:SS
*/
static void GetSerialCmd()
{
  if (Serial.available() > 0)
  {
    delay(100);
    int num_read = Serial.available();
    while (num_read--)
      serial_cmd_rcv += char(Serial.read());
  }
  else return;

  serial_cmd_rcv.trim();

  if (serial_cmd_rcv == "current time")
  {
    PrintfCurTime();
    serial_cmd_rcv = "";
    return;
  }

  Serial.print("Received length: ");
  Serial.println(serial_cmd_rcv.length());

  int indexof_d = serial_cmd_rcv.indexOf('D');
  int indexof_t = serial_cmd_rcv.indexOf('T');

  Serial.print("D index: ");
  Serial.print(indexof_d);
  Serial.print(" T index: ");
  Serial.println(indexof_t);

  if (serial_cmd_rcv.length() != 20 ||
      serial_cmd_rcv.substring(0, 1) != "D" ||
      serial_cmd_rcv.substring(11, 12) != "T") 
  {
    Serial.println(serial_cmd_rcv);
    serial_cmd_rcv = "";
    return;
  }

  Serial.println("Setting time...");

  my_date_str.year = (byte)serial_cmd_rcv.substring(3, 5).toInt();
  my_date_str.month = (byte)serial_cmd_rcv.substring(6, 8).toInt();
  my_date_str.day = (byte)serial_cmd_rcv.substring(9, 11).toInt();
  my_date_str.hour = (byte)serial_cmd_rcv.substring(12, 14).toInt();
  my_date_str.minute = (byte)serial_cmd_rcv.substring(15, 17).toInt();
  my_date_str.second = (byte)serial_cmd_rcv.substring(18).toInt();

  rtc.setYear(my_date_str.year);
  rtc.setMonth(my_date_str.month);
  rtc.setDate(my_date_str.day);
  rtc.setHour(my_date_str.hour);
  rtc.setMinute(my_date_str.minute);
  rtc.setSecond(my_date_str.second);

  serial_cmd_rcv = "";

  Serial.println("Time set.");
}

void setup() {
  // Initialize the I2C interface
  Wire.begin(SDA_PIN, SCL_PIN, 40000);
 
  // Initialize Serial communication
  Serial.begin(115200);
   
  // Set the RTC to 24-hour mode
  rtc.setClockMode(false); // 24-hour format

  // Print current time to Serial Monitor
  PrintfCurTime();

  // Clear any remaining serial data
  while (Serial.read() >= 0) {}
}

void loop() {
  // Process incoming serial commands
  GetSerialCmd();
  delay(1000); // Delay for 1 second
}
arduino ino file download:
.zip   DS3231-RTC.zip (Size: 1.55 KB / Downloads: 21)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   DS3231-RTC.ino.merged.zip (Size: 191.07 KB / Downloads: 19)

Print this item

  [arduino code examples for A6v3]-05 RS232 communication test
Posted by: admin - 01-15-2025, 03:06 AM - Forum: KC868-A6v3 - No Replies

Code:
#include "Arduino.h"

// Define RS232 pins
#define RS232_TXD 9 // TX pin
#define RS232_RXD 10 // RX pin

// Define RS232 communication
HardwareSerial RS232(1); // Use UART1

void setup() {
  // Initialize RS232 serial communication
  RS232.begin(9600, SERIAL_8N1, RS232_RXD, RS232_TXD); // Baud rate 9600, 8 data bits, no parity, 1 stop bit
  Serial.begin(115200); // Debug serial communication

  Serial.println("RS232 Communication Initialized");
}

void loop() {
  static unsigned long lastSendTime = 0;

  // Send a string to RS232 every 5 seconds
  if (millis() - lastSendTime >= 5000) {
    RS232.println("This is KinCony A6v3");
    Serial.println("Sent: This is KinCony A6v3");
    lastSendTime = millis();
  }

  // Check if data is available from RS232
  while (RS232.available()) {
    String receivedData = RS232.readStringUntil('\n'); // Read data from RS232
    RS232.println(receivedData); // Echo the received data back to RS232
    Serial.println("Received and echoed: " + receivedData); // Print the received data to the debug console
  }
}
arduino ino file download:
.zip   RS232.zip (Size: 659 bytes / Downloads: 19)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   RS232.ino.merged.zip (Size: 184.5 KB / Downloads: 22)

Print this item

  [arduino code examples for A6v3]-04 RS485 communication test
Posted by: admin - 01-15-2025, 03:04 AM - Forum: KC868-A6v3 - No Replies

Code:
/*
* Made by KinCony IoT: https://www.kincony.com
*
* RS485 Communication Test with Echo
*
* This program tests RS485 communication using ESP32-S3.
* It sends a message over RS485, reads incoming messages, and echoes them back.
* The TXD pin is defined as GPIO 9 and RXD pin is defined as GPIO 8.
*/

#include <HardwareSerial.h>

// Define RS485 pins
#define RS485_RXD 18
#define RS485_TXD 17

// Create a hardware serial object
HardwareSerial rs485Serial(1);

void setup() {
  // Start serial communication for debugging
  Serial.begin(115200);
  while (!Serial);

  // Initialize RS485 Serial communication
  rs485Serial.begin(9600, SERIAL_8N1, RS485_RXD, RS485_TXD);
 
  Serial.println("RS485 Test Start");
}

void loop() {
  // Send a test message periodically
// rs485Serial.println("Hello from KinCony A32 Pro!");

  // Wait for a short period
  delay(100);

  // Check if data is available to read from RS485
  if (rs485Serial.available()) {
    String receivedMessage = "";
    while (rs485Serial.available()) {
      char c = rs485Serial.read();
      receivedMessage += c;
    }
   
    // Print the received message to the serial monitor
    Serial.print("Received: ");
    Serial.println(receivedMessage);
   
    // Echo the received message back over RS485
    rs485Serial.print("Echo: ");
    rs485Serial.println(receivedMessage);
  }

  // Wait before sending the next message
  delay(2000);
}
arduino ino file download:
.zip   RS485.zip (Size: 810 bytes / Downloads: 22)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   RS485.ino.merged.zip (Size: 184.34 KB / Downloads: 23)

Print this item

  [arduino code examples for A6v3]-03 Read analog input ports value
Posted by: admin - 01-15-2025, 03:00 AM - Forum: KC868-A6v3 - No Replies

Code:
#include "Arduino.h"
#include "PCF8574.h"

#define ANALOG_A1   4
#define ANALOG_A2   5
#define ANALOG_A3   6
#define ANALOG_A4   7

void setup()
{
    Serial.begin(115200);
  pinMode(ANALOG_A1,INPUT);
  pinMode(ANALOG_A2,INPUT);
  pinMode(ANALOG_A3,INPUT);
  pinMode(ANALOG_A4,INPUT);
}

void loop()
{
  Serial.printf("Current Reading A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));
  Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));
  Serial.printf("Current Reading A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));
  Serial.printf("Current Reading A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));
  delay(500);
}
arduino ino file download:
.zip   ADC.zip (Size: 397 bytes / Downloads: 18)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   ADC.ino.merged.zip (Size: 195.06 KB / Downloads: 17)

Print this item

  [arduino code examples for A6v3]-02 Read digital input ports state
Posted by: admin - 01-15-2025, 02:57 AM - Forum: KC868-A6v3 - No Replies

Code:
#include "Arduino.h"
#include "PCF8574.h"

// Set i2c address
PCF8574 pcf8574(0x22);
unsigned long timeElapsed;
void setup()
{
Wire.begin(12, 11); // SDA: GPIO12, SCL: GPIO11
Serial.begin(115200);
delay(1000);

pcf8574.pinMode(P0, INPUT);
pcf8574.pinMode(P1, INPUT);
pcf8574.pinMode(P2, INPUT);
pcf8574.pinMode(P3, INPUT);
pcf8574.pinMode(P4, INPUT);
pcf8574.pinMode(P5, INPUT);
pcf8574.pinMode(P6, INPUT);
pcf8574.pinMode(P7, INPUT);

    Serial.print("Init pcf8574...");
    if (pcf8574.begin()){
        Serial.println("OK");
    }else{
        Serial.println("KO");
    }
}

void loop()
{
uint8_t val1 = pcf8574.digitalRead(P0);
uint8_t val2 = pcf8574.digitalRead(P1);
uint8_t val3 = pcf8574.digitalRead(P2);
uint8_t val4 = pcf8574.digitalRead(P3);
uint8_t val5 = pcf8574.digitalRead(P4);
uint8_t val6 = pcf8574.digitalRead(P5);
uint8_t val7 = pcf8574.digitalRead(P6);
uint8_t val8 = pcf8574.digitalRead(P7);
if (val1==LOW) Serial.println("KEY1 PRESSED");
if (val2==LOW) Serial.println("KEY2 PRESSED");
if (val3==LOW) Serial.println("KEY3 PRESSED");
if (val4==LOW) Serial.println("KEY4 PRESSED");
if (val5==LOW) Serial.println("KEY5 PRESSED");
if (val6==LOW) Serial.println("KEY6 PRESSED");
if (val7==LOW) Serial.println("KEY7 PRESSED");
if (val8==LOW) Serial.println("KEY8 PRESSED");
    delay(300);
}
arduino ino file download:
.zip   8574-DI.zip (Size: 567 bytes / Downloads: 19)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   8574-DI.ino.merged.zip (Size: 191.22 KB / Downloads: 24)

Print this item