Skip to content

Instantly share code, notes, and snippets.

@FreeFly19
Created December 28, 2021 01:52
Show Gist options
  • Save FreeFly19/737c7c3ece5865fb854caaccf2c28a0f to your computer and use it in GitHub Desktop.
Save FreeFly19/737c7c3ece5865fb854caaccf2c28a0f to your computer and use it in GitHub Desktop.
#define IR_SEND_PIN 27
#include <IRremote.h>
int RECV_PIN = 14;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
int lastAddress = 1;
int lastCommand = 1;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(RECV_PIN, INPUT_PULLUP);
}
void loop() {
irsend.sendNEC(lastAddress, lastCommand, 1, false);
delay(1000);
irrecv.enableIRIn();
pinMode(RECV_PIN, INPUT_PULLUP);
delay(500);
if (irrecv.decode() && irrecv.decodedIRData.address != 0) {
lastAddress = irrecv.decodedIRData.address;
lastCommand = irrecv.decodedIRData.command;
irrecv.resume();
Serial.println("Received");
}
irrecv.disableIRIn();
delay(500);
Serial.println(lastAddress);
Serial.println(lastCommand);
Serial.println();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment