SendDemo.ino 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. Example for different sending methods
  3. https://github.com/sui77/rc-switch/
  4. */
  5. #include <RCSwitch.h>
  6. RCSwitch mySwitch = RCSwitch();
  7. void setup() {
  8. Serial.begin(9600);
  9. // Transmitter is connected to Arduino Pin #10
  10. mySwitch.enableTransmit(10);
  11. // Optional set protocol (default is 1, will work for most outlets)
  12. // mySwitch.setProtocol(2);
  13. // Optional set pulse length.
  14. // mySwitch.setPulseLength(320);
  15. // Optional set number of transmission repetitions.
  16. // mySwitch.setRepeatTransmit(15);
  17. }
  18. void loop() {
  19. /* See Example: TypeA_WithDIPSwitches */
  20. mySwitch.switchOn("11111", "00010");
  21. delay(1000);
  22. mySwitch.switchOff("11111", "00010");
  23. delay(1000);
  24. /* Same switch as above, but using decimal code */
  25. mySwitch.send(5393, 24);
  26. delay(1000);
  27. mySwitch.send(5396, 24);
  28. delay(1000);
  29. /* Same switch as above, but using binary code */
  30. mySwitch.send("000000000001010100010001");
  31. delay(1000);
  32. mySwitch.send("000000000001010100010100");
  33. delay(1000);
  34. /* Same switch as above, but tri-state code */
  35. mySwitch.sendTriState("00000FFF0F0F");
  36. delay(1000);
  37. mySwitch.sendTriState("00000FFF0FF0");
  38. delay(1000);
  39. delay(20000);
  40. }