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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,221
» Latest member: cargames
» Forum threads: 3,601
» Forum posts: 18,557

Full Statistics

Online Users
There are currently 21 online users.
» 0 Member(s) | 8 Guest(s)
AhrefsBot, Amazonbot, PetalBot, bot, github.com

Latest Threads
N30 installation for Home...
Forum: N30
Last Post: guy
1 hour ago
» Replies: 13
» Views: 66
Raspberry Pi5 Compute Mod...
Forum: Pi5
Last Post: admin
1 hour ago
» Replies: 1
» Views: 7
KC868-COLB Analog Sensor ...
Forum: Development
Last Post: admin
1 hour ago
» Replies: 8
» Views: 73
E16T is not detected when...
Forum: KC868-E16T
Last Post: admin
7 hours ago
» Replies: 6
» Views: 70
KC868-A16 rs485
Forum: KC868-A16
Last Post: admin
8 hours ago
» Replies: 1
» Views: 6
KC868-COLB Tuya Integrati...
Forum: Development
Last Post: danielyoud401@gmail.com
Yesterday, 01:16 PM
» Replies: 10
» Views: 69
KC868-A8 ESP32 I/O pin de...
Forum: KC868-A8
Last Post: chaoukihasnaoui
Yesterday, 12:05 PM
» Replies: 1
» Views: 3,286
KC868-A2 SIM7600 with Tuy...
Forum: KC868-A2
Last Post: WestfieldGhost
Yesterday, 07:44 AM
» Replies: 30
» Views: 3,005
"KCS" v3.18.0 firmware BI...
Forum: "KCS" v3 firmware
Last Post: admin
Yesterday, 03:11 AM
» Replies: 0
» Views: 21
"KCS" v2.2.18 firmware BI...
Forum: "KCS" v2 firmware system
Last Post: admin
Yesterday, 03:01 AM
» Replies: 0
» Views: 38

  [Arduino source code for KC868-A2]-03 LAN8720_UDP
Posted by: KinCony Support - 03-02-2023, 06:48 AM - Forum: KC868-A2 - Replies (1)

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-A2.zip (Size: 3.15 KB / Downloads: 515)
Print this item

  [Arduino source code for KC868-A2]-02 INPUT
Posted by: KinCony Support - 03-02-2023, 06:47 AM - Forum: KC868-A2 - No Replies

Code:
/*A2 INPUT PIN*/
#define input1  36
#define input2  39

void setup()
{
  Serial.begin(115200);
  pinMode(input1,INPUT);
  pinMode(input2,INPUT);
}

void loop()
{
if (digitalRead(input1)==LOW){
  Serial.println("input1 down");
}
if (digitalRead(input2)==LOW){
  Serial.println("input2 down");
}

}



Attached Files
.zip   KC868-A2.zip (Size: 3.15 KB / Downloads: 487)
Print this item

Heart [Arduino source code for KC868-A2]-01 DS18B20
Posted by: KinCony Support - 03-02-2023, 06:46 AM - Forum: KC868-A2 - No Replies

Code:
#include <DS18B20.h>

DS18B20 ds1(33); 
DS18B20 ds2(14); 
void setup() {
  Serial.begin(115200);
}
void loop() {

      Serial.print("Temperature1 is ");
      Serial.print(ds1.getTempC());
      Serial.println(" C");
      delay(500);
      Serial.print("Temperature2 is ");
      Serial.print(ds2.getTempC());
      Serial.println(" C");
      delay(500);
}



Attached Files
.zip   KC868-A2.zip (Size: 3.15 KB / Downloads: 479)
Print this item

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

Code:
#define BEEP 18
#define S2 0

void setup() {
  Serial.begin(115200);
  pinMode(BEEP,OUTPUT);
  pinMode(S2,INPUT);

  digitalWrite(BEEP, HIGH);
  delay(200);
  digitalWrite(BEEP,LOW);
  delay(200);
   
}

void loop() {

if(digitalRead(S2)==LOW){
  delay(20);
  if(digitalRead(S2)==LOW)
  {
    digitalWrite(BEEP, HIGH);
    delay(100);
    digitalWrite(BEEP, LOW);
    delay(10); 
  } 
}else digitalWrite(BEEP, LOW);
}



Attached Files
.zip   KC868-ASR_BEEP.zip (Size: 102.86 KB / Downloads: 466)
Print this item

  [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: 470)
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: 492)
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: 504)
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: 531)
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: 556)
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: 532)
Print this item