Pages: [1]   Go Down
Author Topic: IR receiver code's  (Read 273 times)
0 Members and 1 Guest are viewing this topic.
Gouda, The Netherlands
Offline Offline
Newbie
*
Karma: 1
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm just starting out with arduino and I'm messing around with an IR receiver, a remote control, and two LED lights. I'm trying to get one of the lights to go on for a second when I press the "1" (IR HEX code=FD08F7) button and the other one when I press the "2" button (IR HEX code=FD8877). I'm using a library called IRremote.h that I found here:
http://www.pjrc.com/teensy/td_libs_IRremote.html

So far only one of the lights works when press ANY button on the remote (so not only the "1" button, as it supposed to do)

Here's my code

Code:
#include <IRremote.h>

const int RECV_PIN = 3;
int led1 = 8;
int led2 = 9;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    if (results.value = 0xFD08F7) {
      digitalWrite(led1, HIGH);   
      delay(1000);             
      digitalWrite(led1, LOW);   
    }
    else if (results.value = 0xFD8877) {
      digitalWrite(led2, HIGH);   
      delay(1000);             
      digitalWrite(led2, LOW);   
    }
        irrecv.resume();
  }
}

If somebody could take a look at it and help me, I would really appreciate it
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    if (results.value = 0xFD08F7) {
This is an assignment statement (=), not an equality test (==).
Logged

Gouda, The Netherlands
Offline Offline
Newbie
*
Karma: 1
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That did the trick thanks a lot!
Logged

Pages: [1]   Go Up
Jump to: