Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1009 B

  1. #include <RemoteReceiver.h>
  2. /*
  3. * Demo for RF remote switch receiver.
  4. * For details, see RemoteReceiver.h!
  5. *
  6. * This sketch shows the received signals on the serial port.
  7. * Connect the receiver to digital pin 2.
  8. */
  9. void setup() {
  10. Serial.begin(115200);
  11. //Initialize receiver on interrupt 0 (= digital pin 2), calls the callback "showCode"
  12. //after 3 identical codes have been received in a row. (thus, keep the button pressed
  13. //for a moment)
  14. //
  15. //See the interrupt-parameter of attachInterrupt for possible values (and pins)
  16. //to connect the receiver.
  17. RemoteReceiver::init(0, 3, showCode);
  18. }
  19. void loop() {
  20. }
  21. //Callback function is called only when a valid code is received.
  22. void showCode(unsigned long receivedCode, unsigned int period) {
  23. //Note: interrupts are disabled. You can re-enable them if needed.
  24. //Print the received code.
  25. Serial.print("Code: ");
  26. Serial.print(receivedCode);
  27. Serial.print(", period duration: ");
  28. Serial.print(period);
  29. Serial.println("us.");
  30. }