Hello everyone,
i am building on a "universal remote" that is supposed to use an Arduino to send IR signals to the individual devices (Projector, HiFi/BluRay, SAT Receiver) in our Home Cinema while it receives the input from another Arduino (the actual Remote) with those
RF Links, because you cannot use 2 IR Receivers/Transmitters in the same room and the IRLib does not support sending and receiving at the same time either.
Now i have no problem using the RF Link/VirtualWire or the IR system individually, but combining them doesn't seem to work as intended. What am I doing wrong?
Much thanks for any advice
//TRANSMITTER (UNO)
#include <VirtualWire.h>
const int ledPin = 13;
const int txPin = 7;
const int button1Pin = 6;
const int button2Pin = 5;
boolean button1State = false;
boolean button2State = false;
void setup() {
vw_set_tx_pin(txPin);
vw_setup(2000);
pinMode(ledPin, OUTPUT);
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
}
void loop() {
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
if(button1State == HIGH){
digitalWrite(ledPin, HIGH);
vw_send((uint8_t *)"]", 1);
delay(500);
}
else if(button2State == HIGH){
digitalWrite(ledPin, HIGH);
vw_send((uint8_t *)"2", 1);
delay(500);
}
digitalWrite(ledPin, LOW);
}
//RECEIVER (MEGA)
#include <IRLib.h>
#include <VirtualWire.h>
const int RxPin = 11;
const int ledPin = 13;
IRsend MySender;
void setup() {
vw_set_rx_pin(RxPin);
vw_setup(2000);
vw_rx_start();
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
uint8_t buflen = VW_MAX_MESSAGE_LEN;
uint8_t buf[buflen];
if(vw_get_message (buf, &buflen)){
for(int i = 0; i < buflen; i++){
Serial.print(buf[i]);
}
Serial.println();
delay(200);
MySender.send(NEC, 0x8b7fa05, 32);
}
}