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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 4,503
» Latest member: sabrinahaven
» Forum threads: 2,287
» Forum posts: 11,894

Full Statistics

Online Users
There are currently 47 online users.
» 3 Member(s) | 30 Guest(s)
AhrefsBot, Bytespider, Google, PetalBot, Yandex, bot, admin, csacomani, sabrinahaven

Latest Threads
PWM support?
Forum: KC868-A16
Last Post: admin
1 hour ago
» Replies: 5
» Views: 25
KC868 A32 Firmware 2.2.4 ...
Forum: KC868-A32/A32 Pro
Last Post: iozzi_giorgio
3 hours ago
» Replies: 2
» Views: 26
[arduino code examples fo...
Forum: KC868-A32/A32 Pro
Last Post: admin
8 hours ago
» Replies: 0
» Views: 3
USB ports
Forum: KinCony Server-Mini / Server-16 Raspberry Pi4 relay module
Last Post: BaconRanch
10 hours ago
» Replies: 2
» Views: 6
Lesson23- How to connect ...
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
Yesterday, 10:11 AM
» Replies: 10
» Views: 7,156
KC868-AG RF - sending rep...
Forum: KC868-A series and Uair Smart Controller
Last Post: PhilW
Yesterday, 07:46 AM
» Replies: 3
» Views: 9
Usar entradas y oled i2c ...
Forum: KC868-A6
Last Post: sistemasyusa
Yesterday, 03:16 AM
» Replies: 4
» Views: 17
a16 as basis for a securi...
Forum: KC868-A16
Last Post: admin
09-18-2024, 11:58 PM
» Replies: 8
» Views: 55
GSM CALL RELAY
Forum: KC868-A2
Last Post: admin
09-18-2024, 11:53 PM
» Replies: 9
» Views: 4,109
KC868-A16S or KC868-A8S
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
09-18-2024, 11:51 PM
» Replies: 3
» Views: 39

  [Arduino source code for KC868-A8M]-05 OUTPUT
Posted by: KinCony Support - 04-14-2023, 03:16 AM - Forum: KC868-A8M - No Replies

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

#define SDA 5
#define SCL 4

PCF8574 pcf8574_RE1(0x24,SDA,SCL);//DO
void setup()
{
    Serial.begin(115200);
for(int i=0;i<=7;i++)
{
   pcf8574_RE1.pinMode(i, OUTPUT);
}
   pcf8574_RE1.begin();

for(int i=0;i<=7;i++)
{
  pcf8574_RE1.digitalWrite(i, LOW);delay(200);
}
for(int i=0;i<=7;i++)
{
  pcf8574_RE1.digitalWrite(i, HIGH);delay(200);
}   
}

void loop()
{
  /******Output is all off by default, and can be turned
on or off manually when pressed by the keypad**************/
for(int i=0;i<=7;i++)
{
  pcf8574_RE1.digitalWrite(i, HIGH);delay(100);
}

}
[Arduino source code for KC868-A8M]-05 OUTPUT



Attached Files
.zip   KC868-A8M_OUTPUT.zip (Size: 664 bytes / Downloads: 155)
Print this item

  [Arduino source code for KC868-A8M]-04 LAN8720_UDP
Posted by: KinCony Support - 04-14-2023, 03:16 AM - Forum: KC868-A8M - No Replies

[Arduino source code for KC868-A8M]-04 LAN8720_UDP

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

// Set it based on the IP address of the router
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
  }
}



Attached Files
.zip   KC868-A8M_LAN8720_UDP.zip (Size: 1.13 KB / Downloads: 165)
Print this item

  [Arduino source code for KC868-A8M]-03 INPUT
Posted by: KinCony Support - 04-14-2023, 03:15 AM - Forum: KC868-A8M - No Replies

Code:
/*KC868-A8M input trigger output*/
#include "Arduino.h"
#include "PCF8574.h"

#define SDA 5
#define SCL 4
// Set i2c address
PCF8574 pcf8574_IN1(0x22,SDA,SCL);
PCF8574 pcf8574_RE(0x24,SDA,SCL);
unsigned long timeElapsed;
void setup()
{
    Serial.begin(115200);
    delay(1000);
    pcf8574_RE.pinMode(P0, OUTPUT);
    pcf8574_RE.pinMode(P1, OUTPUT);
    pcf8574_RE.pinMode(P2, OUTPUT);
    pcf8574_RE.pinMode(P3, OUTPUT);
    pcf8574_RE.pinMode(P4, OUTPUT);
    pcf8574_RE.pinMode(P5, OUTPUT);
    pcf8574_RE.pinMode(P6, OUTPUT);
    pcf8574_RE.pinMode(P7, OUTPUT);
   
    pcf8574_IN1.pinMode(P0, INPUT);
    pcf8574_IN1.pinMode(P1, INPUT);
    pcf8574_IN1.pinMode(P2, INPUT);
    pcf8574_IN1.pinMode(P3, INPUT);
    pcf8574_IN1.pinMode(P4, INPUT);
    pcf8574_IN1.pinMode(P5, INPUT);
    pcf8574_IN1.pinMode(P6, INPUT);
    pcf8574_IN1.pinMode(P7, INPUT);
    pcf8574_IN1.begin();
    pcf8574_RE.begin();
}

void loop()
{
uint8_t val1 = pcf8574_IN1.digitalRead(P0);
uint8_t val2 = pcf8574_IN1.digitalRead(P1);
uint8_t val3 = pcf8574_IN1.digitalRead(P2);
uint8_t val4 = pcf8574_IN1.digitalRead(P3);
uint8_t val5 = pcf8574_IN1.digitalRead(P4);
uint8_t val6 = pcf8574_IN1.digitalRead(P5);
uint8_t val7 = pcf8574_IN1.digitalRead(P6);
uint8_t val8 = pcf8574_IN1.digitalRead(P7);
if (val1==LOW) {
  pcf8574_RE.digitalWrite(P0,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P0,HIGH);
if (val2==LOW) {
  pcf8574_RE.digitalWrite(P1,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P1,HIGH);
if (val3==LOW)  {
  pcf8574_RE.digitalWrite(P2,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P2,HIGH);
if (val4==LOW)  {
  pcf8574_RE.digitalWrite(P3,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P3,HIGH);
if (val5==LOW)  {
  pcf8574_RE.digitalWrite(P4,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P4,HIGH);
if (val6==LOW)  {
  pcf8574_RE.digitalWrite(P5,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P5,HIGH);
if (val7==LOW)  {
  pcf8574_RE.digitalWrite(P6,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P6,HIGH);
if (val8==LOW)  {
  pcf8574_RE.digitalWrite(P7,LOW);
  delay(100);
  }
else pcf8574_RE.digitalWrite(P7,HIGH);

    delay(300);
}
[Arduino source code for KC868-A8M]-03 INPUT



Attached Files
.zip   KC868-A8M_INPUT.zip (Size: 822 bytes / Downloads: 166)
Print this item

  [Arduino source code for KC868-A8M]-02 DS18B20
Posted by: KinCony Support - 04-14-2023, 03:15 AM - Forum: KC868-A8M - Replies (2)

Code:
#include <DS18B20.h>

DS18B20 ds(14);   //IO13

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

void loop() {
 
    Serial.printf("Temperature: %.2f C\n",ds.getTempC());
    delay(1000);
}
[Arduino source code for KC868-A8M]-02 DS18B20



Attached Files
.zip   KC868-A8M_DS18B20.zip (Size: 514 bytes / Downloads: 189)
Print this item

  [Arduino source code for KC868-A8M]-01 ADC
Posted by: KinCony Support - 04-14-2023, 03:15 AM - Forum: KC868-A8M - No Replies

Code:
/*Code for KC868-A8S*/
#include "Arduino.h"

#define ANALOG_A1   34        // IO36 
#define ANALOG_A2   35        // IO39   
#define ANALOG_A3   39        // IO34   
#define ANALOG_A4   36        // IO35   
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()
{
  if(analogRead(ANALOG_A1)!=0)
    {  Serial.printf("A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));delay(500);}
  if(analogRead(ANALOG_A2)!=0)
    {  Serial.printf("A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));delay(500);}
  if(analogRead(ANALOG_A3)!=0)
    {  Serial.printf("A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));delay(500);}
  if(analogRead(ANALOG_A4)!=0)
    {  Serial.printf("A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));delay(500);}

}
[Arduino source code for KC868-A8M]-01 ADC



Attached Files
.zip   KC868-A8M_ADC.zip (Size: 643 bytes / Downloads: 180)
Print this item

  [Arduino source code for KC868-A16S]-06 DS18B20
Posted by: KinCony Support - 04-14-2023, 02:47 AM - Forum: KC868-A16S - No Replies

Code:
#include <DS18B20.h>

#define A16S_RS485_RX  32
#define A16S_RS485_TX  33
#define DL 0
DS18B20 ds(14);

void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,A16S_RS485_RX,A16S_RS485_TX); //A16S
  Serial2.println("A16S RS485 SEND OK");
  pinMode(DL,INPUT);
  Serial2.print(ds.getTempC());
  Serial2.println(" C");
}
void loop() {
  if(digitalRead(DL)==LOW)
  {
    delay(20);
     if(digitalRead(DL)==LOW)
  {
    Serial2.println("Download key ok");
    Serial2.print(ds.getTempC());
    Serial2.println(" C");
   
  }
  }
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());//print rs485 receive
   }
   delay(200);
}
[Arduino source code for KC868-A16S]-06 DS18B20



Attached Files
.zip   A16S_DS18B20.zip (Size: 852 bytes / Downloads: 173)
Print this item

  [Arduino source code for KC868-A16S]-05 LAN8720_UDP
Posted by: KinCony Support - 04-14-2023, 02:46 AM - Forum: KC868-A16S - No Replies

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

// Set it based on the IP address of the router
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
  }
}
[Arduino source code for KC868-A16S]-05 LAN8720_UDP



Attached Files
.zip   A16S_LAN8720_UDP.zip (Size: 1.1 KB / Downloads: 159)
Print this item

  [Arduino source code for KC868-A16S]-04 ADC_code
Posted by: KinCony Support - 04-14-2023, 02:46 AM - Forum: KC868-A16S - No Replies

Code:
#include "Arduino.h"

#define ANALOG_A1   36       
#define ANALOG_A2   34           
#define ANALOG_A3   35       
#define ANALOG_A4   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()
{
  if(digitalRead(ANALOG_A1)!=0){
    Serial.printf("A1 on Pin(%d)=%d\n",ANALOG_A1,analogRead(ANALOG_A1));
  }
  if(digitalRead(ANALOG_A2)!=0){
    Serial.printf("A2 on Pin(%d)=%d\n",ANALOG_A2,analogRead(ANALOG_A2));
  }

  if(digitalRead(ANALOG_A3)!=0){
    Serial.printf("A3 on Pin(%d)=%d\n",ANALOG_A3,analogRead(ANALOG_A3));
  }

  if(digitalRead(ANALOG_A4)!=0){
    Serial.printf("A4 on Pin(%d)=%d\n",ANALOG_A4,analogRead(ANALOG_A4));
  }
  delay(100);

}
[Arduino source code for KC868-A16S]-04 ADC_code



Attached Files
.zip   A16S_ADC.zip (Size: 580 bytes / Downloads: 153)
Print this item

  [Arduino source code for KC868-A16S]-03 433_DECODE
Posted by: KinCony Support - 04-14-2023, 02:46 AM - Forum: KC868-A16S - No Replies

Code:
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(digitalPinToInterrupt(16));   
}

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();
  }
}
[Arduino source code for KC868-A16S]-03 433_DECODE



Attached Files
.zip   A16S_433-decode.zip (Size: 584 bytes / Downloads: 166)
Print this item

  [Arduino source code for KC868-A16S]-02 PCF8574-OUTPUT
Posted by: KinCony Support - 04-14-2023, 02:45 AM - Forum: KC868-A16S - Replies (3)

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);
//  delay(1000);

  // Set pinMode to OUTPUT
  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()
{
  for(int i=0;i<=7;i++)
  {
    pcf8574_1.digitalWrite(i, LOW);
    delay(500);
  }
  for(int j=0;j<=7;j++)
  {
    pcf8574_2.digitalWrite(j,LOW);
    delay(500);
  }
for(int i=0;i<=7;i++)
  {
    pcf8574_1.digitalWrite(i, HIGH);
    delay(500);
  }
  for(int j=0;j<=7;j++)
  {
    pcf8574_2.digitalWrite(j,HIGH);
    delay(500);
  }
 
}
[Arduino source code for KC868-A16S]-02 PCF8574-OUTPUT



Attached Files
.zip   A16S_RELAY_OUT.zip (Size: 717 bytes / Downloads: 194)
Print this item