Go Down

Topic: rc5-led (Read 846 times) previous topic - next topic

Jack

Hi all.

The led on pin3 must go on and off by a signal from my RC5 when i push on the number 1.
My program is not working.
What is wrong?
Regards,
                   Jack.

// rc5_2a ( febr. 2011)
#include <IRremote.h>
#include <IRremoteInt.h>

int ledPin = 3;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  if (results.value = 1) {
    digitalWrite(ledPin,LOW);
    }
  else {
   
    digitalWrite(ledPin,HIGH);
    irrecv.resume(); // Receive the next value
  }
}

AlphaBeta

How does your program behave now? Does it print anything? If so; what?

Jack

Yess,it print the value in Hex from the key's a press, but the led on pin3 does nothing.
          Jack.

AlphaBeta

Code: [Select]
// rc5_2a ( febr. 2011)
#include <IRremote.h>
#include <IRremoteInt.h>

int ledPin = 3;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
 pinMode(ledPin, OUTPUT);
 Serial.begin(9600);
 irrecv.enableIRIn(); // Start the receiver
}

void loop() {
 if (irrecv.decode(&results)) {
   Serial.println(results.value, HEX);
   if (results.value = 1) {
     digitalWrite(ledPin,!digitalRead(ledPin));
   }

   irrecv.resume(); // Receive the next value
 }
}


How about that?

Jack

Hallo AlphaBeta.

There is progres but the led on pin3 is on by push on button 1 but also by push by all the other key's! The Serial monitor give's the good values.
What to do?
                    Jack.

AlphaBeta

Like this:
Code: [Select]
// rc5_2a ( febr. 2011)
#include <IRremote.h>
#include <IRremoteInt.h>

int ledPin = 3;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    if (results.value == 1) {
      digitalWrite(ledPin,!digitalRead(ledPin));
    }

    irrecv.resume(); // Receive the next value
  }
}

Go Up