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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 5,369
» Latest member: icreators
» Forum threads: 2,574
» Forum posts: 13,314

Full Statistics

Online Users
There are currently 60 online users.
» 2 Member(s) | 41 Guest(s)
Amazonbot, Applebot, Bing, Bytespider, Crawl, Google, PetalBot, Yandex, bot, owler, admin, gal

Latest Threads
How can I power multiple ...
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
14 minutes ago
» Replies: 12
» Views: 125
how to use AS ESP32-S3 vo...
Forum: KinCony AS
Last Post: biofects
6 hours ago
» Replies: 13
» Views: 457
change wake up name
Forum: KinCony AS
Last Post: admin
7 hours ago
» Replies: 13
» Views: 97
Problem with IFTTT automa...
Forum: "KCS" firmware system
Last Post: admin
9 hours ago
» Replies: 6
» Views: 47
A32 Pro ESPHome yaml incl...
Forum: KC868-A32/A32 Pro
Last Post: admin
10 hours ago
» Replies: 18
» Views: 188
KC868-A2 ESP32 I/O pin de...
Forum: KC868-A2
Last Post: admin
10 hours ago
» Replies: 8
» Views: 2,267
Need help with configurat...
Forum: KC868-HxB series Smart Controller
Last Post: admin
Yesterday, 04:32 AM
» Replies: 32
» Views: 398
ESP32 S3 set up issue
Forum: Extender module
Last Post: admin
12-17-2024, 11:43 PM
» Replies: 10
» Views: 71
KC868-A8 Schematic
Forum: KC868-A8
Last Post: admin
12-17-2024, 11:40 PM
» Replies: 7
» Views: 51
"KCS" v2.2.8 firmware BIN...
Forum: "KCS" firmware system
Last Post: admin
12-17-2024, 11:38 PM
» Replies: 2
» Views: 182

  [Arduino source code for KC868-ASR]-03 DS18B20
Posted by: KinCony Support - 03-02-2023, 06:38 AM - Forum: KC868-ASR - No Replies

Code:
#include <DS18B20.h>

DS18B20 ds1(32);  //channel-1-DS18b20
DS18B20 ds2(33);  //channel-2-DS18b20


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

void loop() {

Serial.printf("T1:%.2f || T2:%.2f \n",ds1.getTempC(),ds2.getTempC());
delay(1000);
}



Attached Files
.zip   KC868-ASR_DS18B20.zip (Size: 105.14 KB / Downloads: 168)
Print this item

  [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: 185)
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: 168)
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: 220)
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: 222)
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: 229)
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: 213)
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: 199)
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: 189)
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: 212)
Print this item