Remote Control

hi everyone

sorry that the code is without comments
but i only copied that 1:1 and it’s gonna to compile but is not working by pressing 1 to put the led on and 2 to put it off

#include <IRremote.h>
const int RECV_PIN = 11; // the pin the IR receiver is connected to
int ledPin = 13;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
pinMode (ledPin, OUTPUT);

}
 
void loop() 
{
if (irrecv.decode(&results)) {
Serial.println(results.value, DEC);

if (results.value == 16724175)
{
  digitalWrite (13, HIGH);
  }

if (results.value == 16718055)

{digitalWrite (13, LOW);
}

irrecv.resume();
}
}

First, use Ctrl-T in the IDE before you post your code...your style is difficult to read.

Second, what are these magic numbers all about:16724175 and 16718055? I assume they are some kind of signal value or something. If so, make them more readable with something like:

#define TURNON    16724175 
#define TURNOFF   16718055

// more code...

   if (results.value == TURNON)
   {
// more code

Such things makes your code easier to read.

ok

this values are the values if you press the button 1 or 2

#include <IRremote.h>
#define TURNON    16724175 
#define TURNOFF   16718055

const int RECV_PIN = 11; // the pin the IR receiver is connected to
int ledPin = 13;

IRrecv irrecv(RECV_PIN);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
  pinMode (ledPin, OUTPUT);

}

void loop()
{
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);

    if (results.value == TURNON)
    {
      digitalWrite (13, HIGH);
    }

    if (results.value == TURNOFF)

    { digitalWrite (13, LOW);
    }

    irrecv.resume();
  }
}

@econjack I think you posted the answer in the wrong thread. but if you

remove the both files in the following folder too

"Removing the files - libraries\RobotIRremote\IRremoteTools.cpp and libraries\RobotIRremote\IRremoteTools.h"

then it should be fine and should compile

OK, then I’d change them to:

#include <IRremote.h>

#define BUTTON1   16724175 
#define BUTTON2   16718055
#define LEDPIN       13

const int RECV_PIN = 11; // the pin the IR receiver is connected to


IRrecv irrecv(RECV_PIN);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
  pinMode (ledPin, OUTPUT);

}

void loop()
{
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);

    if (results.value == BUTTON1)
    {
      digitalWrite (LEDPIN, HIGH);
    }

    if (results.value == BUTTON2)
    { 
       digitalWrite (LEDPIN, LOW);
    }
    irrecv.resume();
  }
}

Also, you defined ledpin, but never use it. You could change it as shown above. Also, you define RECV_PIN, but never use it. I have a feeling something’s missing here, as you need to probably read that pin before you can react to it.

Ok, as i mentioned, this is a copied code.
but ledPin it is used in pinmode()
and RECV_PIN in 8th line

and i don’t know what is missing cause this all is from here

http://funduino.de/index.php/3-programmieren/nr-11-fernbedienung

it’s german sorry, but the supplemented code with the led mode is in the end of the page

I ended up downloading and installing the library again. I then copied all of the extracted files into a new library directory named IRremote. For my system, this is:

E:\Arduino1.6.5\libraries\IRremote

The new library has a bunch of *.cpp files that appear to be code for various remote control devices. After the new library was installed, it compiled correctly.

econjack: I ended up downloading and installing the library again. I then copied all of the extracted files into a new library directory named IRremote. For my system, this is:

E:\Arduino1.6.5\libraries\IRremote

The new library has a bunch of *.cpp files that appear to be code for various remote control devices. After the new library was installed, it compiled correctly.

my program is also compiling correctly but it does not work. i have tested the remote controlls working with my camera. battery is not empty and so the remote control is working. once the receiver for the Rcontrol was so hot, that i couldn't touch it very long. could it be that i connected the wires wrong and the receiver is now damaged? how can i test that?

hello arduino guys :)

could somebody help me with the question above? maybe my receiver is damaged?

Run the example code that comes with the IR library.