JVCPanasonicSendDemo.ino 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend
  3. * Version 0.1 June, 2015
  4. * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
  5. * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
  6. *
  7. * An IR LED circuit *MUST* be connected to the ESP8266 on a pin
  8. * as specified by kIrLed below.
  9. *
  10. * TL;DR: The IR LED needs to be driven by a transistor for a good result.
  11. *
  12. * Suggested circuit:
  13. * https://github.com/markszabo/IRremoteESP8266/wiki#ir-sending
  14. *
  15. * Common mistakes & tips:
  16. * * Don't just connect the IR LED directly to the pin, it won't
  17. * have enough current to drive the IR LED effectively.
  18. * * Make sure you have the IR LED polarity correct.
  19. * See: https://learn.sparkfun.com/tutorials/polarity/diode-and-led-polarity
  20. * * Typical digital camera/phones can be used to see if the IR LED is flashed.
  21. * Replace the IR LED with a normal LED if you don't have a digital camera
  22. * when debugging.
  23. * * Avoid using the following pins unless you really know what you are doing:
  24. * * Pin 0/D3: Can interfere with the boot/program mode & support circuits.
  25. * * Pin 1/TX/TXD0: Any serial transmissions from the ESP8266 will interfere.
  26. * * Pin 3/RX/RXD0: Any serial transmissions to the ESP8266 will interfere.
  27. * * ESP-01 modules are tricky. We suggest you use a module with more GPIOs
  28. * for your first time. e.g. ESP-12 etc.
  29. */
  30. #ifndef UNIT_TEST
  31. #include <Arduino.h>
  32. #endif
  33. #include <IRremoteESP8266.h>
  34. #include <IRsend.h>
  35. const uint16_t kPanasonicAddress = 0x4004; // Panasonic address (Pre data)
  36. const uint32_t kPanasonicPower = 0x100BCBD; // Panasonic Power button
  37. const uint16_t kJVCPower = 0xC5E8;
  38. const uint16_t kIrLed = 4; // ESP8266 GPIO pin to use. Recommended: 4 (D2).
  39. IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message.
  40. void setup() {
  41. irsend.begin();
  42. }
  43. void loop() {
  44. // This should turn your TV on and off
  45. #if SEND_PANASONIC
  46. irsend.sendPanasonic(kPanasonicAddress, kPanasonicPower);
  47. #else // SEND_PANASONIC
  48. Serial.println("Can't send because SEND_PANASONIC has been disabled.");
  49. #endif // SEND_PANASONIC
  50. #if SEND_JVC
  51. irsend.sendJVC(kJVCPower, 16, 1); // hex value, 16 bits, single repeat
  52. #else // SEND_JVC
  53. Serial.println("Can't send because SEND_JVC has been disabled.");
  54. #endif // SEND_JVC
  55. delay(10000); // Wait 10 seconds before we repeat everything.
  56. }