PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

96 lines
2.4KB

  1. /*
  2. * IRremote: IRrecvDump - dump details of IR codes with IRrecv
  3. * An IR detector/demodulator must be connected to the input RECV_PIN.
  4. * Version 0.1 July, 2009
  5. * Copyright 2009 Ken Shirriff
  6. * http://arcfn.com
  7. * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
  8. * LG added by Darryl Smith (based on the JVC protocol)
  9. */
  10. #include <IRremote.h>
  11. /*
  12. * Default is Arduino pin D11.
  13. * You can change this to another available Arduino Pin.
  14. * Your IR receiver should be connected to the pin defined here
  15. */
  16. int RECV_PIN = 11;
  17. IRrecv irrecv(RECV_PIN);
  18. decode_results results;
  19. void setup()
  20. {
  21. Serial.begin(9600);
  22. irrecv.enableIRIn(); // Start the receiver
  23. }
  24. void dump(decode_results *results) {
  25. // Dumps out the decode_results structure.
  26. // Call this after IRrecv::decode()
  27. int count = results->rawlen;
  28. if (results->decode_type == UNKNOWN) {
  29. Serial.print("Unknown encoding: ");
  30. }
  31. else if (results->decode_type == NEC) {
  32. Serial.print("Decoded NEC: ");
  33. }
  34. else if (results->decode_type == SONY) {
  35. Serial.print("Decoded SONY: ");
  36. }
  37. else if (results->decode_type == RC5) {
  38. Serial.print("Decoded RC5: ");
  39. }
  40. else if (results->decode_type == RC6) {
  41. Serial.print("Decoded RC6: ");
  42. }
  43. else if (results->decode_type == PANASONIC) {
  44. Serial.print("Decoded PANASONIC - Address: ");
  45. Serial.print(results->address, HEX);
  46. Serial.print(" Value: ");
  47. }
  48. else if (results->decode_type == LG) {
  49. Serial.print("Decoded LG: ");
  50. }
  51. else if (results->decode_type == JVC) {
  52. Serial.print("Decoded JVC: ");
  53. }
  54. else if (results->decode_type == AIWA_RC_T501) {
  55. Serial.print("Decoded AIWA RC T501: ");
  56. }
  57. else if (results->decode_type == WHYNTER) {
  58. Serial.print("Decoded Whynter: ");
  59. }
  60. Serial.print(results->value, HEX);
  61. Serial.print(" (");
  62. Serial.print(results->bits, DEC);
  63. Serial.println(" bits)");
  64. Serial.print("Raw (");
  65. Serial.print(count, DEC);
  66. Serial.print("): ");
  67. for (int i = 1; i < count; i++) {
  68. if (i & 1) {
  69. Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
  70. }
  71. else {
  72. Serial.write('-');
  73. Serial.print((unsigned long) results->rawbuf[i]*USECPERTICK, DEC);
  74. }
  75. Serial.print(" ");
  76. }
  77. Serial.println();
  78. }
  79. void loop() {
  80. if (irrecv.decode(&results)) {
  81. Serial.println(results.value, HEX);
  82. dump(&results);
  83. irrecv.resume(); // Receive the next value
  84. }
  85. }