Smart Home Automation Forum

Full Version: [Arduino source code for KC868-A4S]-01 RS485
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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);

}