Hi everyone!
I am building a small device that will be able to get data from my remote controller in order to use it to automate a few devices at home (tv, air conditioning).
This is the code I have, obtained from the examples in the respective libraries:
// IR Transmitter Library
#include <IRTransmitter.h>
// IR Receiver Library
#include <IRremote.h>
// Here we specify the infrared led pin
#define IR_PIN D4
// Here we specify the visual feedback led pin
#define LED_PIN D7
// Here we specify the infrared receiver pin
int RECV_PIN = D2;
// Stored codes variables
unsigned int code1 = 0;
// Initializing IRReceiver
IRrecv irrecv(RECV_PIN);
decode_results results;
// Initializing IRTransmitter
IRTransmitter transmitter(IR_PIN, LED_PIN);
// Raw data example
unsigned int data[67] = {9000, 4450, 550, 550, 600, 500, 600, 550, 550, 1650, 600, 550, 550, 550, 600, 500, 600, 550,
600, 1600, 600, 1650, 600, 1650, 600, 500, 600, 1650, 600, 1600, 600, 1650, 600, 1650, 600,
500, 600, 1650, 600, 1650, 550, 550, 600, 1650, 550, 550, 600, 500, 600, 550, 550, 1650,
600, 550, 550, 550, 600, 1650, 550, 550, 600, 1650, 550, 1650, 650, 1600,
600}; // NEC 10EF6897
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
// Receiving IR signal and printing it using serial port
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if (code1 == 0) {
code1 = results.value;
}
irrecv.resume(); // Receive the next value
}
if (code1 != 0) {
// Sending via IR data
transmitter.Transmit(code1, sizeof(code1) / sizeof(code1[0]));
}
// Sending via IR data (using example data, works)
//transmitter.Transmit(data, sizeof(data) / sizeof(data[0]));
}
The receiver works perfectly and prints output to the serial port.
For example if I push āoffā on the tv remote it prints: 1000C
Now I do not understand how should I proceed to feed this information into the IR transmitter.
My attempt in the code would not even compileā¦
Can you please suggest me what to check?
Thanks for your time and kind help.