Pages: [1]   Go Down
Author Topic: rc5-led  (Read 694 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
  }
}
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
// 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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Like this:
Code:
// 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
  }
}
Logged

Pages: [1]   Go Up
Jump to: