Created
December 28, 2021 01:52
-
-
Save FreeFly19/737c7c3ece5865fb854caaccf2c28a0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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