Next time, please start with that... The thing with getting a good reply is you need to provide good information, I don't have a crystal ball. And if I did had one, I surely wouldn't go around and checking other people's codes!!!
I cannot get it to work. Here is my full code. There are no syntax errors, it compiles okay. But looks like it cannot compare my hex values? (I removed the servo moving part, instead there is just a string for testing)
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Servo.h>
Servo myservo;Â
int pos = 30;Â Â
int receiver = 2;
int newIR = 0;Â Â
int prevIR = 0;
IRrecv irrecv(receiver);Â Â Â Â Â
decode_results results;Â Â Â Â Â
void setup()Â {
 Serial.begin(9600);
 Serial.println("serial monitor works");
 irrecv.enableIRIn();
 myservo.attach(13);Â
}
void loop()Â
{
 if (irrecv.decode(&results))
 {
  newIR = results.value;
      if((newIR == 0xFF42BD) && (prevIR == 0xFF52AD))
          {
          Serial.println("this should show up if it works");
          }
  prevIR = newIR;
  Serial.println(results.value, HEX);
  Serial.println("this button was pressed");
  Serial.println(newIR, HEX);
  delay(500);
  irrecv.resume();
 }Â
}
okay, finally I managed to figure out, using the draft of C-F-K. Thanks again. Here is my working code:
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Servo.h>
Servo myservo;Â
int pos = 30;Â Â
int receiver = 2;
String newIR = "";Â Â
String prevIR = "";
IRrecv irrecv(receiver);Â Â Â Â Â
decode_results results;Â Â Â Â Â
void setup()Â {
 Serial.begin(9600);
 Serial.println("serial monitor works");
 irrecv.enableIRIn();
 myservo.attach(13);Â
}
void loop()Â
{
 if (irrecv.decode(&results))
 {
  newIR = String(results.value);
Â
      if((newIR == "16728765") && (prevIR == "16732845"))
          {
         Â
          Serial.println(" open lock");
          myservo.write(150);
          }
      if((newIR == "16726215"))
          {
        Â
          Serial.println(" close lock");
          myservo.write(100);
          }
 Â
  Serial.println(results.value, HEX);
  Serial.println("this button was pressed");
  Serial.println(newIR);
  delay(500);
  irrecv.resume();
  prevIR = newIR;
 }Â
}
cybercy: I cannot get it to work. Here is my full code. There are no syntax errors, it compiles okay. But looks like it cannot compare my hex values? (I removed the servo moving part, instead there is just a string for testing)
Try it again, but use this instead:
unsigned long newIR = 0;
unsigned long prevIR = 0;
As what PaulS said, they need to be unsigned long int's. A normal int is only 2 bytes, so 0xFF42BD doesn't even fit. An unsigned long is 4 bytes, so it'll fit just snug!