I'm interested in know how to build an remote control range extender or repeater for home or office use. Do you have any idea how to code it?
There are lots of Google results for Arduino IR repeater.
1 Like
Hi!
This code works for me.
//Código que repete os sinais dos controles do projetor e do receptor de TV.
#include <IRremote.h>
#include <IRremoteInt.h>
const int RECV_PIN = 2;
const int STATUS_PIN = 13;
const int RELAY_PIN = 4;
const int SENSOR_PIN = A0;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;
bool relay_state;
unsigned long millis_temp;
float desired_tempeture = 40; // Temperatura desejada para acionamento do ventilador.
/*
// Storage for the raw data
unsigned int rawCodes[35];
int codeLen;
*/
void blink()
{
digitalWrite(STATUS_PIN, HIGH);
delay(100);
digitalWrite(STATUS_PIN, LOW);
}
void check_temp()
{
float temperature = (analogRead(SENSOR_PIN) * (4.11 / 1024) * 100);
// Serial.println(temperature);
if (temperature > desired_tempeture)
{
digitalWrite(RELAY_PIN, HIGH);
}
else
{
digitalWrite(RELAY_PIN, LOW);
}
}
/*
void extractRaw (decode_results *results) {
codeLen = results->rawlen - 1;
// To store raw codes:
// Drop first results.value (gap)
// Convert from ticks to microseconds
// Tweak marks shorter, and spaces longer
// to cancel out IR receiver distortion
for (int i = 1; i <= codeLen; i++)
if (i % 2)
// Mark
rawCodes[i - 1] = results->rawbuf[i] * USECPERTICK - MARK_EXCESS;
else
// Space
rawCodes[i - 1] = results->rawbuf[i] * USECPERTICK + MARK_EXCESS;
}*/
void setup()
{
// Serial.begin(9600);
//Serial.println("Hello!");
pinMode(STATUS_PIN, OUTPUT);
pinMode(RELAY_PIN, OUTPUT);
pinMode(SENSOR_PIN, INPUT);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if ((millis() - millis_temp) > 60000UL)
{
check_temp();
millis_temp = millis();
}
if (irrecv.decode(&results))
{
blink();
//extractRaw(&results);
irrecv.resume(); // resume receiver
if (results.value == 0xFFA956) // up
{
//Serial.println("UP");
irsend.sendNEC(0xFF609F, 32);
}
else if (results.value == 0xFF59A6) // down
{
//Serial.println("DOWN");
irsend.sendNEC(0xFF6897, 32);
}
else if (results.value == 0xFFD926) // left
{
//Serial.println("LEFT");
irsend.sendNEC(0xFF5AA5, 32);
}
else if (results.value == 0xFF9966) // right
{
//Serial.println("RIGHT");
irsend.sendNEC(0xFFD827, 32);
}
else if (results.value == 0xFFC936) // menu
{
//Serial.println("MENU");
irsend.sendNEC(0xFFA25D, 32);
}
else if (results.value == 0xFF25DA) // back
{
//Serial.println("BACK");
irsend.sendNEC(0xFFA05F, 32);
}
else if (results.value == 0xFF15EA) // power
{
//Serial.println("POWER");
irsend.sendNEC(0xFF9A65, 32);
}
else if (results.value == 0xFF7986) // ok
{
//Serial.println("OK");
irsend.sendNEC(0xFF58A7, 32);
}
if (results.value == 0xFF31CE) // Aumenta volume soundbar
{
//Serial.println("Soundbar vol +");
irsend.sendSAMSUNG(0x3434E817, 32);
delay(50);
}
else if (results.value == 0xFF39C6) // Diminui volume soundbar
{
//Serial.println("Soundbar vol - ");
irsend.sendSAMSUNG(0x34346897, 32);
delay(50);
}
else if (results.value == 0xFF11EE) // Mute
{
//Serial.println("Soundbar mute");
irsend.sendSAMSUNG(0x3434F807, 32);
delay(50);
}
else if (results.value == 0xFF19E6) // Funçao
{
//Serial.println("Soundbar muda funçao");
irsend.sendSAMSUNG(0x343451AE, 32);
delay(50);
}
else if (results.value == 0xFF41BE) // Sound effect
{
//Serial.println("Soundbar sound effect");
irsend.sendSAMSUNG(0x3434F40B, 32);
delay(50);
}
else
{
//Serial.println("None");
delay(50);
irsend.sendNEC(results.value, 32);
//irsend.sendRaw(rawCodes, codeLen, 38);
}
irrecv.enableIRIn(); // Re-enable receiver
}
}
Best regards.
1 Like
Yeah. But some of them are incomplete and doesn't work correctly
Thank you. I will try it
Try starting one, then you can ask for help if you run into a specific issue.
1 Like
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.