mirror of
https://github.com/hzkincony/kc868-arduino-library.git
synced 2024-11-09 23:28:26 +01:00
38 lines
563 B
C++
38 lines
563 B
C++
#include "KC868.h"
|
|
|
|
|
|
KC868 kc868(&Serial2); //create kc868 object
|
|
|
|
void setup() {
|
|
|
|
Serial.begin(115200);
|
|
|
|
delay(2000);
|
|
|
|
kc868.begin(115200);//begin kc868 with baud 115200
|
|
|
|
boolean ret = kc868.writeSwitch(2,1); //open relay 2
|
|
Serial.printf("open relay 2 ");
|
|
if(ret)
|
|
Serial.println("success!");
|
|
else
|
|
Serial.println("fail.");
|
|
|
|
delay(2000);
|
|
|
|
ret = kc868.writeSwitch(2,0); //close relay 2
|
|
Serial.printf("close relay 2 ");
|
|
if(ret)
|
|
Serial.println("success!");
|
|
else
|
|
Serial.println("fail.");
|
|
|
|
}
|
|
|
|
|
|
void loop(){
|
|
|
|
kc868.poll();
|
|
|
|
}
|