I am a novice to Arduino Uno, I just started messing around with a kit I bought online. I am trying to receive signal from IR remote via IR sensor but I only receive '0' for every button pressed on remote.
#include<IRremote.h>
int recv_pin = 11;
IRrecv receiver(recv_pin);
decode_results results;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
receiver.enableIRIn();
}
void loop() {
// put your main code here, to run repeatedly:
if(receiver.decode()){
Serial.println(results.value, HEX);
receiver.resume();
}
}
Try this version of the code posted in the original post.
#include<IRremote.h>
int recv_pin = 11;
IRrecv receiver(recv_pin);
decode_results results;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
receiver.enableIRIn();
}
void loop()
{
// put your main code here, to run repeatedly:
if (receiver.decode(&results)) // ******** added &results (a place to store the key code)
{
Serial.println(results.value, HEX);
receiver.resume();
}
}
I also use version 2.8 of the IRRemote library. Don't like the newer versions.
biaisjp, how did you manage to take up so much dead space?
And check your compiler output for a warning like this:
"warning: 'bool IRrecv::decode(decode_results*)' is deprecated: You should use decode() without a parameter. [-Wdeprecated-declarations]"
groundFungus:
Try this version of the code posted in the original post.
#include<IRremote.h>
int recv_pin = 11;
IRrecv receiver(recv_pin);
decode_results results;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
receiver.enableIRIn();
}
void loop()
{
// put your main code here, to run repeatedly:
if (receiver.decode(&results)) // ******** added &results (a place to store the key code)
{
Serial.println(results.value, HEX);
receiver.resume();
}
}
I also use version 2.8 of the IRRemote library. Don't like the newer versions.
biaisjp, how did you manage to take up so much dead space?
I get a warning: "bool IRrecv::decode(decode_results*)' is deprecated: You should use decode() without a parameter. [-Wdeprecated-declarations]"when i try to write receiver.decode(&results)
and i am using IRremote library version 3.0.0
And check your compiler output for a warning like this:
"warning: 'bool IRrecv::decode(decode_results*)' is deprecated: You should use decode() without a parameter. [-Wdeprecated-declarations]"
I changed the code as you mentioned but it is sttill shows '0' serial monitor
here is the changed code
Can you confirm that your remote is transmitting? Many cell phone cameras are sensitive to IR light. Press some buttons on the remote while watching the IR transmit LED with the phone camera. Do you see it flashing?
void loop()
{
if (IrReceiver.decode())
{
Serial.println(IrReceiver.decodedIRData.command);
IrReceiver.resume();
}
}
Output
IR Receive test
24
3
8
8
17
72
72
Can you confirm that your remote is transmitting? Many cell phone cameras are sensitive to IR light. Press some buttons on the remote while watching the IR transmit LED with the phone camera. Do you see it flashing?
Thank you for the assistance. I am able to receive from irremote now, guess my code was not good