* Updated examples to use the new NewRemodeCode::on, ::off, ::dim and ::on_with_dim notation.
66 lines
1.6 KiB
Arduino
66 lines
1.6 KiB
Arduino
/*
|
|
* Demo for RF remote switch receiver.
|
|
* This example is for the new KaKu / Home Easy type of remotes!
|
|
|
|
* For details, see NewRemoteReceiver.h!
|
|
*
|
|
* This sketch shows the received signals on the serial port.
|
|
* Connect the receiver to digital pin 2.
|
|
*/
|
|
|
|
#include <NewRemoteReceiver.h>
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
|
|
// Initialize receiver on interrupt 0 (= digital pin 2), calls the callback "showCode"
|
|
// after 2 identical codes have been received in a row. (thus, keep the button pressed
|
|
// for a moment)
|
|
//
|
|
// See the interrupt-parameter of attachInterrupt for possible values (and pins)
|
|
// to connect the receiver.
|
|
NewRemoteReceiver::init(0, 2, showCode);
|
|
}
|
|
|
|
void loop() {
|
|
}
|
|
|
|
// Callback function is called only when a valid code is received.
|
|
void showCode(NewRemoteCode receivedCode) {
|
|
// Note: interrupts are disabled. You can re-enable them if needed.
|
|
|
|
// Print the received code.
|
|
Serial.print("Addr ");
|
|
Serial.print(receivedCode.address);
|
|
|
|
if (receivedCode.groupBit) {
|
|
Serial.print(" group");
|
|
} else {
|
|
Serial.print(" unit ");
|
|
Serial.print(receivedCode.unit);
|
|
}
|
|
|
|
switch (receivedCode.switchType) {
|
|
case NewRemoteCode::off:
|
|
Serial.print(" off");
|
|
break;
|
|
case NewRemoteCode::on:
|
|
Serial.print(" on");
|
|
break;
|
|
case NewRemoteCode::dim:
|
|
Serial.print(" dim level ");
|
|
Serial.print(receivedCode.dimLevel);
|
|
break;
|
|
case NewRemoteCode::on_with_dim:
|
|
Serial.print(" on with dim level ");
|
|
Serial.print(receivedCode.dimLevel);
|
|
break;
|
|
}
|
|
|
|
Serial.print(", period: ");
|
|
Serial.print(receivedCode.period);
|
|
Serial.println("us.");
|
|
}
|
|
|
|
|