Able to receive IR signal, show them in serial monitor and depending on received code print some text.
Able to send RF signal, turning on and off lights succesfully.
Not able to make combination. When combining IR stil receives successfully, but RF signal is not sended properly.
From what I understand of all the library code it might be a timer / interrupt issue. I believe both libraries use the same timer (timer2), IR interrupts every 50 uS, RF every 260 uS. So i guess RF signal is broken every time by the shorter IR interrupt (but I might be wrong, as my programming skills are below average).
/*
IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
An IR detector/demodulator must be connected to the input RECV_PIN.
Version 0.1 July, 2009
Copyright 2009 Ken Shirriff
http://arcfn.com
*/
// based on IRremote and NewRemoteTransmitter code, this sketch tries to combine
// receiving IR and sending RF
#include <IRremote.h>
#include <NewRemoteTransmitter.h>
IRrecv irrecv(11);
decode_results results;
NewRemoteTransmitter transmitter(7996130, 10, 260, 3);
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
switch (results.value)
{
case 0xA55A50AF:
Serial.println("Plus");
transmitter.sendGroup(true);
// delay(5000);
break;
case 0xA55AD02F:
Serial.println("Minus");
transmitter.sendGroup(false);
// delay(5000);
break;
default : break;
}
irrecv.resume(); // Receive the next value
}
}
The NewRemoteTransmitter has a constructor that diddles with the hardware before the hardware is ready to be diddled with.
From what I understand of all the library code it might be a timer / interrupt issue.
The IR receiver uses a timer. The RF transmitter does not. It bit-bangs the timing.
If you comment out the irrecv stuff, and simply call transmitter.sendGroup() in loop(), does that work?