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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 4,971
» Latest member: itzgreenpoiis0
» Forum threads: 2,423
» Forum posts: 12,543

Full Statistics

Online Users
There are currently 35 online users.
» 1 Member(s) | 20 Guest(s)
Bing, Bytespider, Crawl, Google, PetalBot, WordPress/, Yandex, bot, Philadam

Latest Threads
Sms relays control
Forum: KC868-A8S
Last Post: Michele
10 hours ago
» Replies: 6
» Views: 21
new home automation
Forum: DIY Project
Last Post: admin
11 hours ago
» Replies: 1
» Views: 7
Energy consumption not me...
Forum: KC868-M16 / M1 / MB / M30
Last Post: sebastianfs
Today, 05:26 AM
» Replies: 2
» Views: 30
M30 energy consumption no...
Forum: KC868-M16 / M1 / MB / M30
Last Post: admin
Yesterday, 11:51 PM
» Replies: 1
» Views: 8
[Arduino IDE demo source ...
Forum: KC868-A16
Last Post: admin
Yesterday, 11:49 PM
» Replies: 10
» Views: 2,948
KC868-A8 board esphome + ...
Forum: KC868-A8
Last Post: admin
Yesterday, 11:47 PM
» Replies: 9
» Views: 50
Nextion display work with...
Forum: KC868-A4
Last Post: admin
Yesterday, 11:47 AM
» Replies: 5
» Views: 1,924
New KC868-A32 Arduino ESP...
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
Yesterday, 11:45 AM
» Replies: 3
» Views: 17
A16 and HC-SR04
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
Yesterday, 11:44 AM
» Replies: 1
» Views: 27
KC868-A4 with Nextion 5 i...
Forum: KC868-A4
Last Post: YOO SEOK
Yesterday, 01:54 AM
» Replies: 2
» Views: 2,823

Rainbow [Arduino IDE demo source code for KC868-A16]--#08-PCF8574-DO
Posted by: KinCony Support - 01-05-2022, 08:27 AM - Forum: KC868-A16 - Replies (10)

Code 7: //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_1(0x24,4,5);
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);


    Serial.print("Init pcf8574_1...");
    if (pcf8574_1.begin()){
        Serial.println("PCF8574_1_OK");
    }else{
        Serial.println("PCF8574_1_KO");
    }

  Serial.print("Init pcf8574_2...");
  if (pcf8574_2.begin()){
    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);
}
   
   

Print this item

Rainbow [Arduino IDE demo source code for KC868-A16]--#07-PCF8574-DI
Posted by: KinCony Support - 01-05-2022, 08:26 AM - Forum: KC868-A16 - Replies (4)

Code 6: //The demo code is PCF8574-DI    You can copy the code to your Arduino IDE

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

// Set i2c input address 
PCF8574 pcf8574_1(0x22,4,5);  // channel 1-8    address: 100010
PCF8574 pcf8574_2(0x21,4,5);  //channel 9-16    address: 100001



unsigned long timeElapsed;
void setup()
{
    Serial.begin(115200);
    delay(1000);
pcf8574_1.pinMode(P0, INPUT);
pcf8574_1.pinMode(P1, INPUT);
pcf8574_1.pinMode(P2, INPUT);
pcf8574_1.pinMode(P3, INPUT);
pcf8574_1.pinMode(P4, INPUT);
pcf8574_1.pinMode(P5, INPUT);
pcf8574_1.pinMode(P6, INPUT);
pcf8574_1.pinMode(P7, INPUT);

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

    Serial.print("Init pcf8574...");
    if (pcf8574_1.begin()){
        Serial.println("pcf8574_1_OK");
    }else{
        Serial.println("pcf8574_1_KO");
    }

  Serial.print("Init pcf8574...");
  if (pcf8574_2.begin()){
    Serial.println("pcf8574_2_OK");
  }else{
    Serial.println("pcf8574_2_KO");
  }


}

void loop()
{
uint8_t val1 = pcf8574_1.digitalRead(P0);
uint8_t val2 = pcf8574_1.digitalRead(P1);
uint8_t val3 = pcf8574_1.digitalRead(P2);
uint8_t val4 = pcf8574_1.digitalRead(P3);
uint8_t val5 = pcf8574_1.digitalRead(P4);
uint8_t val6 = pcf8574_1.digitalRead(P5);
uint8_t val7 = pcf8574_1.digitalRead(P6);
uint8_t val8 = pcf8574_1.digitalRead(P7);

uint8_t val9 = pcf8574_2.digitalRead(P0);
uint8_t val10 = pcf8574_2.digitalRead(P1);
uint8_t val11 = pcf8574_2.digitalRead(P2);
uint8_t val12 = pcf8574_2.digitalRead(P3);
uint8_t val13 = pcf8574_2.digitalRead(P4);
uint8_t val14 = pcf8574_2.digitalRead(P5);
uint8_t val15 = pcf8574_2.digitalRead(P6);
uint8_t val16 = pcf8574_2.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");

if (val9==LOW) Serial.println("KEY1 PRESSED");
if (val10==LOW) Serial.println("KEY2 PRESSED");
if (val11==LOW) Serial.println("KEY3 PRESSED");
if (val12==LOW) Serial.println("KEY4 PRESSED");
if (val13==LOW) Serial.println("KEY5 PRESSED");
if (val14==LOW) Serial.println("KEY6 PRESSED");
if (val15==LOW) Serial.println("KEY7 PRESSED");
if (val16==LOW) Serial.println("KEY8 PRESSED");
delay(300);
}
   
   

Print this item

Rainbow [Arduino IDE demo source code for KC868-A16]--#06-LAN8720-UDP
Posted by: KinCony Support - 01-05-2022, 08:06 AM - Forum: KC868-A16 - No Replies

Code 5: //The demo code is LAN8720-UDP    You can copy the code to your Arduino IDE

Code:
#include <ETH.h>
#include <WiFiUdp.h>

#define ETH_ADDR        0
#define ETH_POWER_PIN  -1
#define ETH_MDC_PIN    23
#define ETH_MDIO_PIN   18
#define ETH_TYPE       ETH_PHY_LAN8720
#define ETH_CLK_MODE   ETH_CLOCK_GPIO17_OUT

WiFiUDP Udp;                      //Create UDP object
unsigned int localUdpPort = 4196; //local port
IPAddress local_ip(192, 168, 1, 200);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192, 168, 1, 1);

void setup()
{
  Serial.begin(115200);
  Serial.println();
  
  ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE); //start with ETH

  // write confir for static IP, gateway,subnet,dns1,dns2
  if (ETH.config(local_ip, gateway, subnet, dns, dns) == false) {
    Serial.println("LAN8720 Configuration failed.");
  }else{Serial.println("LAN8720 Configuration success.");}
 
/* while(!((uint32_t)ETH.localIP())) //wait for IP
  {

  }*/
  Serial.println("Connected");
  Serial.print("IP Address:");
  Serial.println(ETH.localIP());

  Udp.begin(localUdpPort); //begin UDP listener
}

void loop()
{
  int packetSize = Udp.parsePacket(); //get package size
  if (packetSize)                     //if have received data
  {
    char buf[packetSize];
    Udp.read(buf, packetSize); //read current data

    Serial.println();
    Serial.print("Received: ");
    Serial.println(buf);
    Serial.print("From IP: ");
    Serial.println(Udp.remoteIP());
    Serial.print("From Port: ");
    Serial.println(Udp.remotePort());

    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); //ready to send data
    Udp.print("Received: ");   
    Udp.write((const uint8_t*)buf, packetSize); //copy data to sender buffer
    Udp.endPacket();            //send data
  }
}
   

Print this item

Rainbow [Arduino IDE demo source code for KC868-A16]--#05-DS18B20
Posted by: KinCony Support - 01-05-2022, 08:04 AM - Forum: KC868-A16 - No Replies

Code4: //The demo code is DS18B20    You can copy the code to your Arduino IDE

Code:
#include <DS18B20.h>

#define LOW_ALARM 10
#define HIGH_ALARM 15

DS18B20 ds(33);   //PIN #33
uint8_t address[] = {40, 168, 111, 11, 44, 32, 1, 185};
uint8_t selected;

void setup() {
  Serial.begin(9600);
  selected = ds.select(address);

  if (selected) {
    ds.setAlarms(LOW_ALARM, HIGH_ALARM);
  } else {
    Serial.println("Device not found!");
  }
}

void loop() {
  if (selected) {
    if (ds.hasAlarm()) {
      Serial.print("Warning! Temperature is ");
      Serial.print(ds.getTempC());
      Serial.println(" C");
    }
  } else {
    Serial.println("Device not found!");
  }

  //delay(10000);
}
       

Print this item

Rainbow [Arduino IDE demo source code for KC868-A16]--#04-ADC INPUT
Posted by: KinCony Support - 01-05-2022, 08:01 AM - Forum: KC868-A16 - No Replies

Code 3: //The demo code is ADC INPUT    You can copy the code to your Arduino IDE

Code:
#include "Arduino.h"

#define ANALOG_A1   36
#define ANALOG_A2   34
#define ANALOG_A1   35
#define ANALOG_A2   39

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

  pinMode(ANALOG_A1,INPUT);
  pinMode(ANALOG_A2,INPUT);
  pinMode(ANALOG_A3,INPUT);
  pinMode(ANALOG_A4,INPUT);
}

void loop()
{
  delay(500);
  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 A1 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));
  Serial.printf("Current Reading A2 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));
}

Print this item

Rainbow [Arduino IDE demo source code for KC868-A16]--#03-RF receive
Posted by: KinCony Support - 01-05-2022, 07:58 AM - Forum: KC868-A16 - No Replies

Code 2: //The demo code is RF-receive    You can copy the code to your Arduino IDE

Code:
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(digitalPinToInterrupt(2));   //Receive pin IO02
}

void loop() {
  if (mySwitch.available()) {
   
    Serial.print("Received ");
    Serial.print( mySwitch.getReceivedValue() );
    Serial.print(" / ");
    Serial.print( mySwitch.getReceivedBitlength() );
    Serial.print("bit ");
    Serial.print("Protocol: ");
    Serial.println( mySwitch.getReceivedProtocol() );

    mySwitch.resetAvailable();
  }
}



Attached Files Thumbnail(s)
   
Print this item

Rainbow [Arduino IDE demo source code for KC868-A16]--#02-RF send
Posted by: KinCony Support - 01-05-2022, 07:53 AM - Forum: KC868-A16 - No Replies

Code 1: //The demo code is RF-send  You can copy the code to your Arduino IDE

Code:
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

  Serial.begin(9600);
 
  // Transmitter is connected to Arduino Pin #15 
  mySwitch.enableTransmit(15);
}

void loop() {

  /* See Example: TypeA_WithDIPSwitches */
  mySwitch.switchOn("11111", "00010");
  delay(1000);
  mySwitch.switchOff("11111", "00010");
  delay(1000);

  /* Same switch as above, but using decimal code */
  mySwitch.send(5393, 24);
  delay(1000); 
  mySwitch.send(5396, 24);
  delay(1000); 

  /* Same switch as above, but using binary code */
  mySwitch.send("000000000001010100010001");
  delay(1000); 
  mySwitch.send("000000000001010100010100");
  delay(1000);

  /* Same switch as above, but tri-state code */
  mySwitch.sendTriState("00000FFF0F0F");
  delay(1000); 
  mySwitch.sendTriState("00000FFF0FF0");
  delay(1000);
}
   

Print this item

Rainbow [Arduino IDE demo source code for KC868-A16]--#01-config Arduino IDE for ESP32 module
Posted by: KinCony Support - 01-05-2022, 07:47 AM - Forum: KC868-A16 - Replies (2)

 Before using KC868-A16, you need to set the parameters of the preference
Copy the following URL: https://dl.espressif.com/dl/package_esp32_index.json


   
   
   

.pdf   KC868-A16-schematic.pdf (Size: 794.92 KB / Downloads: 629)

Print this item

Star [Arduino IDE demo source code for KC868-A8]--#09-RF SEND
Posted by: KinCony Support - 01-05-2022, 07:20 AM - Forum: KC868-A8 - No Replies

Code 8: //The demo code is RF-send  You can copy the code to your Arduino IDE

Code:
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

  Serial.begin(9600);
 
  // Transmitter is connected to Arduino Pin #2 
  mySwitch.enableTransmit(2);
}

void loop() {

  /* See Example: TypeA_WithDIPSwitches */
  mySwitch.switchOn("11111", "00010");
  delay(1000);
  mySwitch.switchOff("11111", "00010");
  delay(1000);

  /* Same switch as above, but using decimal code */
  mySwitch.send(5393, 24);
  delay(1000); 
  mySwitch.send(5396, 24);
  delay(1000); 

  /* Same switch as above, but using binary code */
  mySwitch.send("000000000001010100010001");
  delay(1000); 
  mySwitch.send("000000000001010100010100");
  delay(1000);

  /* Same switch as above, but tri-state code */
  mySwitch.sendTriState("00000FFF0F0F");
  delay(1000); 
  mySwitch.sendTriState("00000FFF0FF0");
  delay(1000);
}
   

Print this item

Star [Arduino IDE demo source code for KC868-A8]--#08-Serial control relays
Posted by: KinCony Support - 01-05-2022, 07:12 AM - Forum: KC868-A8 - No Replies

Code 7: //The demo code is SERIAL-CONTROL-RELAY    You can copy the code to your Arduino IDE

Code:
#include "Arduino.h"
#include "PCF8574.h"
PCF8574 pcf8574(0x24);
char cmd='0';
void setup(){
  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);

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

  pcf8574.digitalWrite(P0, HIGH);
  pcf8574.digitalWrite(P1, HIGH);
  pcf8574.digitalWrite(P2, HIGH);
  pcf8574.digitalWrite(P3, HIGH);
  pcf8574.digitalWrite(P4, HIGH);
  pcf8574.digitalWrite(P5, HIGH);
  pcf8574.digitalWrite(P6, HIGH);
  pcf8574.digitalWrite(P7, HIGH);
  }
}

void loop(){
  while(Serial.available())  // To Get up ALL Serial data
  {
    cmd=Serial.read();
   
  }

    if (cmd=='1')
    {
      pcf8574.digitalWrite(P0, LOW);
      Serial.println("You've turned on the Relay");
      cmd = '0';
    }
    else if(cmd == '2')
    {
      pcf8574.digitalWrite(P0, HIGH);
      Serial.println("You've turned off the Relay");
      cmd = '0';
    }
}
   

Print this item