I received a Sony amplifier/receiver from a friend, but I didn't get the remote control for it.
I really need the remote as there are some important functions that I can't access without it. So I dedided to replace the remote with an Arduino+IR LED.
So far so good, I had some progress.
Using the IRRemote library I can test with the example sketch IRsendDemo. It uses the Sony protocol that is explained here:
I managed to find the device type as Cassete Deck/Tuner as it responded to the Power on/off commands. And some muting/volume commands.
I can construct the command in HEX format and I send it to the Sony unit via that sketch that sends it once every 5 seconds.
Now, since this is so time consuming finding (calculating) the right codes to get me into the menu, I decided it's best if I manage to input the codes in HEX format from the console, and then the Arduino would send them via the IR LED.
This is where I am stuck. Because the code is 12bit long, and I have no idea on how to read these 12bits from the console and send them to the IR.
This is the code for the example sketch:
#include <IRremote.h>
IRsend irsend;
void setup()
{
}
void loop() {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0x481, 12);
delay(40);
}
delay(5000); //5 second delay between each signal burst
}
The arguments for the irsend.sendSony function are code in HEX (0x481) and number of bits (12 always in this case).
Anyway, this should be a great tutorial on how to replace your lost remotes! Sadly I can't even borrow one to "steal" the codes but there's a few lists with the most common functions, and anyway I can test for codes. But putting one in the sketch, then uploading it every time I test a code is time consuming. Would be great to input the codes from the console.
Also it would be useful to input the code in binary as well (I think it's more recommended actually in this testing phase).
Later on, I might get a keypad and make a more permanent setup but I only really need to adjust a few settings regarding the output levels on each speaker etc. I can move my ass and manually adjust the volume, but no way I can access those configuration items without a remote (I've checked).
So, any ideas on how to read bytes from the console and send them to the IR LED?
I just found the codes for my remote! At this website they have loads of codes for remote controls:
Now, I have used the older AV1 format for my tests, but it seems these are AV2 format in 15bits.
So I prefer to use this format so I can make use of all these codes. The whole remote control is mapped, so I only need to use the codes to browse the menus.
Now, I need a way to input the codes from console, as the menu has a time-out usually and it's a pain to navigate up/down and make settings with having to upload each time I change a code.
int x;
String str;
int y;
#include <IRremote.h>
IRsend irsend;
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available() > 0)
{
str = Serial.readStringUntil('\n');
x = Serial.parseInt();
remo();
}
}
void remo () {
for (int i = 0; i < 3; i++) {
irsend.sendSony(str, 15);
delay(40);
}
}
I get this error:
Applications/Arduino.app/Contents/Java/libraries/Arduino-IRremote-master/IRremote.h:275:10: note: void IRsend::sendSony(long unsigned int, int)
void sendSony (unsigned long data, int nbits) ;
^
/Applications/Arduino.app/Contents/Java/libraries/Arduino-IRremote-master/IRremote.h:275:10: note: no known conversion for argument 1 from 'String' to 'long unsigned int'
Since you know all the codes I suggest baking them into the program and making up key commands that you type into the console, using your keyboard as a remote.
I found a sketch that I made early in a project to test out sending codes to my Blu-ray player. It interprets 'a' and 's' as volume up /down and 'l' and 'r' as remote arrows left and right.
It sure seem easier than typing in commands.
/*
IR Remote
*/
#include <IRremote.h>
IRsend irsend;
void setup()
{
Serial.begin(9600);
}
byte inKey;
void loop() {
if( Serial.available() )
{
inKey = Serial.read();
switch(inKey)
{
case 's':
case 'S':
// volume up
for (int i = 0; i < 3; i++) {
irsend.sendNEC(0x20df40bf, 32); // volume up
delay(40);
} // for
break;
case 'a':
case 'A':
// volume down
for (int i = 0; i < 3; i++) {
irsend.sendNEC(0x20dfc03f, 32); // volume down
delay(40);
} // for
break;
case 'l':
case 'L':
// left
irsend.sendNEC(0x20dfE01F, 32); // arrow left
delay(40);
break;
case 'r':
case 'R':
// right
irsend.sendNEC(0x20df609F, 32); // arrow right
delay(40);
break;
case 'o':
case 'O':
// OK
irsend.sendNEC(0x20df22DD, 32); // OK
delay(40);
break;
case 'u':
case 'U':
irsend.sendNEC(0x20df827D, 32); // arrow down
delay(40);
break;
case 'b':
case 'B':
// back
irsend.sendNEC(0x20df14EB, 32); // go back
delay(40);
break;
default:
Serial.println(inKey);
break;
} // break
} // if
}