Hey,
i need a little help,
i have make a program for mij remote controller from the tv i will 1 button use for more inputs on the AMP,
the program is the reciever side of the arduino 2,4ghz
My problem are in the pice of else if (msg[0] == 115) {
delay(10);
if count 1
SendCodeTV(); //iff count is 1 go to TV
delay(10);
sender.send(NEC, 0x20FF40BF, 12); // HDMI SWITCH poort 1
if count 2
SendCodePS3() // if count is 2 go to ps3
delay(10);
sender.send(NEC, 0x20FF20DF, 12); // HDMI SWITCH poort 2
if count 3
SendCodePC() // if count is 3 go to PC
delay(10);
sender.send(NEC, 0x20FF609F, 12); // HDMI SWITCH poort 3
if next push go to 1
// HDMI SWITCH
//Poort 1 NEC 0x20FF40BF TV
//poort 2 NEC 0x20FF20DF pc
//Poort 3 NEC 0x20FF609F ps3
//Poort 4 NEC 0x20FFE01F
//Poort 5 NEC 0x20FF906F
//DENON versterker
//CD = TV
//Tuner
//DVD/VDP= PC
//TV/DBS = PS3
//
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <IRLib.h>
int msg[1];
RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int IRledPin = 5;
IRsend sender;// sender tv pin 3
void setup(void) {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
}
void loop(void) {
if (radio.available()) {
bool done = false;
while (!done) {
done = radio.read(msg, 1);
Serial.println(msg[0]);
if (msg[0] == 111) {
delay(5);
SendCodeVolumeUp();
delay(5);
SendCodeVolumeUp();
delay(5);
SendCodeVolumeUp();
}
else if (msg[0] == 112) {
delay(7);
SendCodeVolumeDown();
delay(7);
SendCodeVolumeDown();
delay(7);
SendCodeVolumeDown();
delay(7);
SendCodeVolumeDown();
}
else if (msg[0] == 113) {
delay(10);
SendCodeON();
}
else if (msg[0] == 114) {
delay(10);
SendCodeTuner();
}
else if (msg[0] == 115) {
delay(10);
if count 1
SendCodeTV(); //iff count is 1 go to TV
delay(10);
sender.send(NEC, 0x20FF40BF, 12); // HDMI SWITCH poort 1
if count 2
SendCodePS3() // if count is 2 go to ps3
delay(10);
sender.send(NEC, 0x20FF20DF, 12); // HDMI SWITCH poort 2
if count 3
SendCodePC() // if count is 3 go to PC
delay(10);
sender.send(NEC, 0x20FF609F, 12); // HDMI SWITCH poort 3
if next push go to 1
}
}
}
}
// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}