Hi there im getting problems when trying to check each code of each button on my IR remote.
everytime I try a button I only get "FFFFFFFF" on the Serial Monitor
This is the code
#include <IRremote.h>
int receptor = 24;
int led = 7;
IRrecv irrecv(receptor);
decode_results code;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(irrecv.decode(&code))
{
Serial.println(code.value, HEX);
if (code.value==0xFF6897)
{
digitalWrite(led,HIGH);
}
if (code.value==0xFF30CF)
{
digitalWrite(led,LOW);
}
delay(500);
irrecv.resume();
}
}
If I recall correctly, 0xFFFFFFFF is often used as the repeat code that is sent when a key on the remote is held down. Are you sure that the initial code received is not just scrolling up the screen ?
As a quick and dirty test try adding a delay(500) immediately after printing the received code
Where did you get the values that you are testing for ?
I added the delay just after the println but didn't solve it
#include <IRremote.h>
int receptor = 24;
int led = 7;
IRrecv irrecv(receptor);
decode_results code;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(irrecv.decode(&code))
{
Serial.println(code.value, HEX);
delay(500);
if (code.value==0xFF6897)
{
digitalWrite(led,HIGH);
}
if (code.value==0xFF30CF)
{
digitalWrite(led,LOW);
}
delay(500);
irrecv.resume();
}
}
Forget all that. There is a discovery sketch that comes with the IR library, designed to identify the protocol. It should be able to decode and give you the correct codes for your remote.
Once you have those, you can re-write your sketch to use the working codes.
I want to get the correct codes from my buttons '1' and '2' to use them to open/close a door with a servo (check code)
// Check if IR signal is received
if (irrecv.decode(&results)) {
switch (results.value) {
case 0xC: // IR code for button 1
doorServo.write(doorOpenAngle);
digitalWrite(yellowLedPin, HIGH);
lcd.clear();
lcd.print("Door is open");
doorIsOpen = true;
break;
case 0x18: // IR code for button 2
doorServo.write(doorCloseAngle);
digitalWrite(yellowLedPin, LOW);
lcd.clear();
lcd.print("Door is closed");
doorIsOpen = false;
break;
}
irrecv.resume(); // Receive the next value
}
}
But I don't know how to get the correct HEX code to be able to use the remote. Funny enough If I plug the IR receiver to where I coded a pushbutton it kinda works but with every key that I press.
Okay, angle of photo doesn't show the grill in front to the sensor.
Can you post connection diagram with pin names, that receiver PCB looks like it is repurposed from another component module.
What version of the IRremote library do you have installed. The posted code is for an older version (< 3.0) of the library and may not work right with the newer library versions.