Go Down

Topic: IR receiver code's (Read 775 times) previous topic - next topic



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:

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: [Select]
#include <IRremote.h>

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

void setup()
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

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

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


Code: [Select]
    if (results.value = 0xFD08F7) {
This is an assignment statement (=), not an equality test (==).
The art of getting good answers lies in asking good questions.


That did the trick thanks a lot!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131