Smart Home Automation Forum
[Arduino source code for KC868-A4S]-01 RS485 - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A4S (https://www.kincony.com/forum/forumdisplay.php?fid=41)
+--- Thread: [Arduino source code for KC868-A4S]-01 RS485 (/showthread.php?tid=2625)



[Arduino source code for KC868-A4S]-01 RS485 - KinCony Support - 03-02-2023

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

}