kc868-arduino-library/examples/10-sensor change hook/10-sensor change hook.ino

29 lines
434 B
Arduino
Raw Normal View History

2022-10-08 16:43:22 +02:00
#include "KC868.h"
KC868 kc868(&Serial2); //create kc868 object
void SensorUpdate(uint8_t idx, uint8_t state)
{
Serial.printf("Sensor %d : %d\n",idx,state); //state ,0:sensor triggered , 1:sensor not triggered
}
void setup() {
Serial.begin(115200);
delay(2000);
kc868.begin(115200);//begin kc868 with baud 115200
kc868.setSensorChangeHook(SensorUpdate);//set sensor change hook
}
void loop(){
kc868.poll();
}