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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,424
» Latest member: pvc patches canada
» Forum threads: 3,666
» Forum posts: 18,982

Full Statistics

Online Users
There are currently 40 online users.
» 1 Member(s) | 18 Guest(s)
AhrefsBot, Amazonbot, Bing, Bytespider, Google, PetalBot, Semrush, bot

Latest Threads
flash Kincony software to...
Forum: DIY Project
Last Post: guycaluwaerts
59 minutes ago
» Replies: 15
» Views: 90
KC868-A2 SIM7600 with Tuy...
Forum: KC868-A2
Last Post: WestfieldGhost
8 hours ago
» Replies: 34
» Views: 3,988
KC868-A16 v1 with KCS v2....
Forum: "KCS" v2 firmware system
Last Post: admin
9 hours ago
» Replies: 9
» Views: 69
B24M output mosfet relay ...
Forum: B24M
Last Post: admin
9 hours ago
» Replies: 1
» Views: 7
Feedback: Product line di...
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
Today, 08:07 AM
» Replies: 1
» Views: 20
Not able to connect
Forum: KC868-E16S/E16P
Last Post: admin
Today, 06:54 AM
» Replies: 1
» Views: 10
"KCS" v3.19.0 firmware BI...
Forum: "KCS" v3 firmware
Last Post: admin
Today, 01:17 AM
» Replies: 0
» Views: 29
KC868-A6 - how to connect...
Forum: KC868-A6
Last Post: admin
Yesterday, 10:06 PM
» Replies: 10
» Views: 148
F8 physical on device swi...
Forum: F8
Last Post: admin
Yesterday, 10:05 PM
» Replies: 3
» Views: 18
flash kc868-a4
Forum: KC868-A series and Uair Smart Controller
Last Post: Sten
Yesterday, 01:09 PM
» Replies: 14
» Views: 580

  [Arduino source code for KC868-ASR]-02 Relay ON AND OFF
Posted by: KinCony Support - 03-02-2023, 06:37 AM - Forum: KC868-ASR - No Replies

Code:
#define OUT0 19
#define OUT1 5
void setup() {
  Serial.begin(115200);

  pinMode(OUT0,OUTPUT);
  pinMode(OUT1,OUTPUT);   
}

void loop() {
      digitalWrite(OUT0, HIGH);
      delay(200);
      digitalWrite(OUT1, HIGH);
      delay(200); 
      digitalWrite(OUT0,LOW);
      delay(200);
      digitalWrite(OUT1, LOW);
      delay(200);
}



Attached Files
.zip   KC868-ASR_RELAY.zip (Size: 102.81 KB / Downloads: 522)
Print this item

  [Arduino source code for KC868-ASR]-01 LED ON AND OFF
Posted by: KinCony Support - 03-02-2023, 06:36 AM - Forum: KC868-ASR - No Replies

Code:
#define LED1 23
#define LED2 22

void setup() {
  Serial.begin(115200);
  pinMode(LED1,OUTPUT);
  pinMode(LED2,OUTPUT);
   
}

void loop() {

  digitalWrite(LED1, LOW);
  delay(200);
  digitalWrite(LED2, LOW);
  delay(200);
  digitalWrite(LED1, HIGH);
  delay(200);
  digitalWrite(LED2, HIGH);
  delay(200);
}



Attached Files
.zip   KC868-ASR_LED.zip (Size: 102.79 KB / Downloads: 527)
Print this item

  [Arduino source code for KC868-A4S]-07 OUTPUT PWM
Posted by: KinCony Support - 03-02-2023, 05:31 AM - Forum: KC868-A4S - No Replies

Code:
/***************************************************
****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#define SDA  4
#define SCL  16
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);
int brightness = 0;   
int fadeAmount = 64;   
void setup() {
  Serial.begin(9600);
  Serial.println("16 channel PWM test!");
  Wire.begin(SDA,SCL,100000);
  pwm.begin();
  pwm.setOscillatorFrequency(27000000);
 
  pwm.setPWMFreq(1000);  // 1600 This is the maximum PWM frequency

  // if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
  // some i2c devices dont like this so much so if you're sharing the bus, watch
  // out for this!
  Wire.setClock(400000);
}

void loop() {
  // Drive each PWM in a 'wave'
  /* for (uint16_t i=0; i<4096; i += 8) {
    for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
      pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );
    }
  }*/
  
   for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
      pwm.setPWM(pwmnum, 0, brightness );
    }
    brightness = brightness + fadeAmount;
   if (brightness == 0 || brightness == 4096) {
    fadeAmount = -fadeAmount ;
  }
  Serial.println(brightness);            
   delay(20);
   
 
  

 
}



Attached Files
.zip   A4S_PWM.zip (Size: 1.23 KB / Downloads: 552)
Print this item

  [Arduino source code for KC868-A4S]-06 LAN8720
Posted by: KinCony Support - 03-02-2023, 05:29 AM - Forum: KC868-A4S - 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
  }
}



Attached Files
.zip   A4S_Lan8720.zip (Size: 1.07 KB / Downloads: 576)
Print this item

  [Arduino source code for KC868-A4S]-05 DS18B20
Posted by: KinCony Support - 03-02-2023, 05:29 AM - Forum: KC868-A4S - No Replies

Code:
/*KC868-A4S DS18B20 CODE*/
#include <DS18B20.h>
DS18B20 ds1(5);  //channel-1-DS18b20
DS18B20 ds2(14);  //channel-2-DS18b20

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

void loop()
{
  Serial.print("Temperature1:");
  Serial.print(ds1.getTempC());
  Serial.println(" C /");
  delay(100);
  Serial.print("Temperature2:");
  Serial.print(ds2.getTempC());
  Serial.println(" C /\n");
  delay(100); 
}



Attached Files
.zip   A4S_DS18B20.zip (Size: 529 bytes / Downloads: 555)
Print this item

  [Arduino source code for KC868-A4S]-04 DO
Posted by: KinCony Support - 03-02-2023, 05:28 AM - Forum: KC868-A4S - No Replies

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


#define A4S_SDA 4
#define A4S_SCL 16
TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1);

PCF8574 pcf8574_RE1(&I2Cone,0x24,A4S_SDA,A4S_SCL);//DO
/*PCF8574 pcf8574_RE2(&I2Cone,0x21,A4S_SDA,A4S_SCL);//DO
PCF8574 pcf8574_IN1(&I2Ctwo,0x22,A4S_SDA,A4S_SCL);//DI
PCF8574 pcf8574_IN2(&I2Ctwo,0x24,A4S_SDA,A4S_SCL);//DI*/


void setup()
{
    Serial.begin(115200);
    pcf8574_RE1.pinMode(P0, OUTPUT);
    pcf8574_RE1.pinMode(P1, OUTPUT);
    pcf8574_RE1.pinMode(P2, OUTPUT);
    pcf8574_RE1.pinMode(P3, OUTPUT);
   
    pcf8574_RE1.pinMode(P4, INPUT);
    pcf8574_RE1.pinMode(P5, INPUT);
    pcf8574_RE1.pinMode(P6, INPUT);
    pcf8574_RE1.pinMode(P7, INPUT);
    pcf8574_RE1.begin();
}

void loop()
{
/* pcf8574_RE1.digitalWrite(P0, HIGH);delay(1000);
  pcf8574_RE1.digitalWrite(P1, HIGH);delay(1000);
  pcf8574_RE1.digitalWrite(P2, HIGH);delay(1000);
  pcf8574_RE1.digitalWrite(P3, HIGH);delay(1000);
 
  pcf8574_RE1.digitalWrite(P0, LOW);delay(1000);
  pcf8574_RE1.digitalWrite(P1, LOW);delay(1000);
  pcf8574_RE1.digitalWrite(P2, LOW);delay(1000);
  pcf8574_RE1.digitalWrite(P3, LOW);delay(1000);*/
 
  if(pcf8574_RE1.digitalRead(P4)==LOW)
  {
    Serial.println("D09 PRESSED");
    pcf8574_RE1.digitalWrite(P0, LOW);
    }else pcf8574_RE1.digitalWrite(P0, HIGH);
    delay (100);
  if(pcf8574_RE1.digitalRead(P5)==LOW)
  {
    Serial.println("D10 PRESSED");
    pcf8574_RE1.digitalWrite(P1, LOW);
    }else pcf8574_RE1.digitalWrite(P1, HIGH);
    delay (100);
  if(pcf8574_RE1.digitalRead(P6)==LOW)
  {
    Serial.println("D11 PRESSED");
    pcf8574_RE1.digitalWrite(P2, LOW);
    }else pcf8574_RE1.digitalWrite(P2, HIGH);
    delay (100);
  if(pcf8574_RE1.digitalRead(P7)==LOW)
  {
    Serial.println("D12 PRESSED");
    pcf8574_RE1.digitalWrite(P3, LOW);
    }else pcf8574_RE1.digitalWrite(P3, HIGH);
    delay (100);
  delay(20);


}



Attached Files
.zip   A4S_DO.zip (Size: 737 bytes / Downloads: 532)
Print this item

  [Arduino source code for KC868-A4S]-03 DI
Posted by: KinCony Support - 03-02-2023, 05:27 AM - Forum: KC868-A4S - No Replies

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

// Set i2c address
PCF8574 pcf8574_IN1(0x22,4,16);
unsigned long timeElapsed;
void setup()
{
    Serial.begin(115200);
    delay(1000);

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();
}

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) {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(20);
}



Attached Files
.zip   A4S_DI.zip (Size: 651 bytes / Downloads: 536)
Print this item

  [Arduino source code for KC868-A4S]-02 ADC
Posted by: KinCony Support - 03-02-2023, 05:25 AM - Forum: KC868-A4S - No Replies

Code:
#include "Arduino.h"

#define ANALOG_A1   36        // IO36 
#define ANALOG_A2   39        // IO39   
#define ANALOG_A3   34        // IO34   
#define ANALOG_A4   35        // 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()
{
  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 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));
}



Attached Files
.zip   A4S_ADC.zip (Size: 567 bytes / Downloads: 549)
Print this item

  [Arduino source code for KC868-A4S]-01 RS485
Posted by: KinCony Support - 03-02-2023, 05:23 AM - Forum: KC868-A4S - No Replies

Code:
/*********************************
**********************************/
#define A4S_RS485_RX 33
#define A4S_RS485_TX 32
void setup() {
  Serial.begin(115200);
  pinMode(0,INPUT);
  Serial2.begin(115200,SERIAL_8N1,A4S_RS485_RX,A4S_RS485_TX);//A4S
  Serial2.println("A4S  485 TEST");
}

void loop() {
   if(digitalRead(0)==LOW)
  {
    delay(20);
     if(digitalRead(0)==LOW)
  {
    Serial2.println("Download key ok");
  }
  }
 
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());//print rs485 receive
   }
  delay(200);

}



Attached Files
.zip   A4S_485.zip (Size: 582 bytes / Downloads: 544)
Print this item

  A32 Input voltage range
Posted by: Shaps77 - 03-02-2023, 05:16 AM - Forum: KC868-A32/A32 Pro - Replies (5)

What is the acceptable tolerance of the input voltage for the KC868-A32?

Print this item