Skip to content

Instantly share code, notes, and snippets.

@matrixfox
Created May 28, 2017 16:13
Show Gist options
  • Save matrixfox/d08b043d9260cfd7aa917938c0a15425 to your computer and use it in GitHub Desktop.
Save matrixfox/d08b043d9260cfd7aa917938c0a15425 to your computer and use it in GitHub Desktop.
NodeMCU IR
/*
* IRremoteESP8266: IRsendGCDemo - demonstrates sending Global Cache-formatted IR codes with IRsend
* An IR LED must be connected to ESP8266 pin 0.
* Version 0.1 30 March, 2016
* Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
*/
#include <IRremoteESP8266.h>
IRsend irsend(4); //an IR emitter led is connected to GPIO pin 4
void setup()
{
irsend.begin();
Serial.begin(115200);
}
void loop() {
Serial.println("Toggling power");
irsend.sendNEC(0x124815A2, 32);
delay(10000);
}
/*
* IRremoteESP8266: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 Sept, 2015
* Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
*/
#include <IRremoteESP8266.h>
int RECV_PIN = 2; //an IR detector/demodulatord is connected to GPIO pin 2
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment