2017-11-19 17:02:03 +00:00
|
|
|
/*
|
|
|
|
* IRremoteESP8266: IRrecvDemo - demonstrates receiving IR codes with IRrecv
|
2018-11-20 14:53:56 +00:00
|
|
|
* This is very simple teaching code to show you how to use the library.
|
|
|
|
* If you are trying to decode your Infra-Red remote(s) for later replay,
|
2020-06-24 20:48:33 +01:00
|
|
|
* use the IRrecvDumpV2.ino (or later) example code instead of this.
|
2018-11-20 14:53:56 +00:00
|
|
|
* An IR detector/demodulator must be connected to the input kRecvPin.
|
2017-11-19 17:02:03 +00:00
|
|
|
* Copyright 2009 Ken Shirriff, http://arcfn.com
|
|
|
|
* Example circuit diagram:
|
2019-07-21 15:01:43 +01:00
|
|
|
* https://github.com/crankyoldgit/IRremoteESP8266/wiki#ir-receiving
|
2017-11-19 17:02:03 +00:00
|
|
|
* Changes:
|
|
|
|
* Version 0.2 June, 2017
|
|
|
|
* Changed GPIO pin to the same as other examples.
|
|
|
|
* Used our own method for printing a uint64_t.
|
|
|
|
* Changed the baud rate to 115200.
|
|
|
|
* Version 0.1 Sept, 2015
|
|
|
|
* Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <IRremoteESP8266.h>
|
|
|
|
#include <IRrecv.h>
|
|
|
|
#include <IRutils.h>
|
|
|
|
|
|
|
|
// An IR detector/demodulator is connected to GPIO pin 14(D5 on a NodeMCU
|
|
|
|
// board).
|
2020-02-03 18:41:35 +00:00
|
|
|
// Note: GPIO 16 won't work on the ESP8266 as it does not have interrupts.
|
2018-11-20 14:53:56 +00:00
|
|
|
const uint16_t kRecvPin = 14;
|
2017-11-19 17:02:03 +00:00
|
|
|
|
2018-11-20 14:53:56 +00:00
|
|
|
IRrecv irrecv(kRecvPin);
|
2017-11-19 17:02:03 +00:00
|
|
|
|
|
|
|
decode_results results;
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
Serial.begin(115200);
|
|
|
|
irrecv.enableIRIn(); // Start the receiver
|
2018-11-20 14:53:56 +00:00
|
|
|
while (!Serial) // Wait for the serial connection to be establised.
|
|
|
|
delay(50);
|
|
|
|
Serial.println();
|
|
|
|
Serial.print("IRrecvDemo is now running and waiting for IR message on Pin ");
|
|
|
|
Serial.println(kRecvPin);
|
2017-11-19 17:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
if (irrecv.decode(&results)) {
|
|
|
|
// print() & println() can't handle printing long longs. (uint64_t)
|
|
|
|
serialPrintUint64(results.value, HEX);
|
|
|
|
Serial.println("");
|
|
|
|
irrecv.resume(); // Receive the next value
|
|
|
|
}
|
|
|
|
delay(100);
|
|
|
|
}
|