user19890: Question
Is there a reason for unstable button numbers of an IR remote?
Desciption
I wrote a remote class where I identify the pressed number of the remote to set states. But however I get never the same number of the pressed key.
For example I press the number '1' and on the serial interface shows this:
3588650484
2740290906
3148594742
689746115
2396927248
2934053595
4294967295
3876827360

And it should look like this:
16724175 // Button 1
4294967295
16724175 // Button 1
16724175 // Button 1
16724175 // Button 1
16724175 // Button 1

Hardware
I am using an arduino UNO board and the standart remote of the starter kit. There is no name just 'SPECIAL FOR MP3'.
Some more infos
Ok, in my first project I used the code from Noreddine Kessa(Example Project) which works fine. Next I copied some code in my new class 'IRControl.cpp' ( you can see below). Then I created an object IRControl in the main.cpp and run the menu() in the loop.
h-File:
/*
 * IRControl.h
 *
 *  Created on: 04.04.2016
 *      Author: David
 */

#ifndef IRCONTROL_H_
#define IRCONTROL_H_

//Remote Defines
#define buttonON 16753245
#define buttonMode 16736925
#define buttonSoundOff 16769565
#define buttonPlayStop 16743045
#define buttonTrackBack 16712445
#define buttonTrackForward 16761405
#define buttonEQ 16769055
#define buttonMinus 16754775
#define buttonPlus 16748655
#define button0 16738455
#define buttonRepeat 16750695
#define buttonJSD 16756815
#define button1 16724175
#define button2 16718055
#define button3 16743045
#define button4 16716015
#define button5 16726215
#define button6 16734885
#define button7 16728765
#define button8 16730805

#include "IRremote.h"
#include "wiring_private.h"

enum zustaende{Motor1, Motor2, Motor3, Sleep};
extern int zustand;

class IRControl {
private:
    IRrecv *irrecv;
    decode_results remoteValue;
public:
    IRControl(int RECV_PIN);
    virtual ~IRControl();
    void menu();
};

#endif /* IRCONTROL_H_ */

cpp-File:
* IRControl.cpp
 *
 *  Created on: 04.04.2016
 *      Author: David
 */

#include "IRControl.h"

IRControl::IRControl(int RECV_PIN) {
    // TODO Auto-generated constructor stub
    irrecv = new IRrecv(RECV_PIN);
    pinMode(RECV_PIN , INPUT);
    irrecv->enableIRIn();
}

IRControl::~IRControl() {
    // TODO Auto-generated destructor stub
    delete irrecv;
}

void IRControl::menu() {
    if (irrecv->decode(&remoteValue)) {
        //lReceived = remoteValue.value ;
        Serial.println(remoteValue.value);
        /*
        switch(remoteValue.value)
                {
                case button1:
                    zustand = Motor1;
                    //digitalWrite (LED1, HIGH); // for control
                    break;

                case button2:
                    zustand = Motor2;
                    //digitalWrite (LED2, HIGH);
                    break;
                case button3:
                    zustand = Motor3;
                    //digitalWrite (LED3, HIGH);
                    break;

                case button0:
                    zustand = Sleep;
                    break;

                default: break;
                }
                */
        irrecv->resume(); // Receive the next value
      }
}

Where the problem could be
I think there could be a problem with the IRrecv *irrecv;. But i'm not sure.
Thanks for your help

user10794: Please post the code where you call the library. In particular where do you make an instance of IRControl?
I am guessing you are doing it at global scope which means you are probably running into the C++ static initialization order fiasco.
What it is: http://www.parashift.com/c++-faq/static-init-order.html
How to prevent it: http://www.parashift.com/c++-faq/static-init-order-on-first-use.html
To prevent this, you should not be doing this in the class constructor:
irrecv = new IRrecv(RECV_PIN);
pinMode(RECV_PIN , INPUT);
irrecv->enableIRIn();

Instead, make a begin function (like most Arduino classes do) and call that from setup.

19890: <p><strong>Question</strong></p>

<p>Is there a reason for unstable button numbers of an IR remote?</p>

<p><strong>Desciption</strong></p>

<p>I wrote a remote class where I identify the pressed number of the remote to set states. But however I get never the same number of the pressed key.</p>

<p>For example I press the number '1' and on the serial interface shows this:</p>

<pre><code>3588650484
2740290906
3148594742
689746115
2396927248
2934053595
4294967295
3876827360
</code></pre>

<p>And it should look like this:</p>

<pre><code>16724175 // Button 1
4294967295
16724175 // Button 1
16724175 // Button 1
16724175 // Button 1
16724175 // Button 1
</code></pre>

<p><strong>Hardware</strong></p>

<p>I am using an arduino UNO board and the standart remote of the starter kit. There is no name just 'SPECIAL FOR MP3'.</p>

<p><strong>Some more infos</strong></p>

<p>Ok, in my first project I used the code from Noreddine Kessa(<a href="http://www.instructables.com/id/Controlling-an-Arduino-Board-Using-an-Infrared-Rem/" rel="nofollow">Example Project</a>) which works fine. Next I copied some code in my new class 'IRControl.cpp' ( you can see below). Then I created an object IRControl in the main.cpp and run the menu() in the loop.</p>

<p>h-File:</p>

<pre><code>/*
 * IRControl.h
 *
 *  Created on: 04.04.2016
 *      Author: David
 */

#ifndef IRCONTROL_H_
#define IRCONTROL_H_

//Remote Defines
#define buttonON 16753245
#define buttonMode 16736925
#define buttonSoundOff 16769565
#define buttonPlayStop 16743045
#define buttonTrackBack 16712445
#define buttonTrackForward 16761405
#define buttonEQ 16769055
#define buttonMinus 16754775
#define buttonPlus 16748655
#define button0 16738455
#define buttonRepeat 16750695
#define buttonJSD 16756815
#define button1 16724175
#define button2 16718055
#define button3 16743045
#define button4 16716015
#define button5 16726215
#define button6 16734885
#define button7 16728765
#define button8 16730805

#include "IRremote.h"
#include "wiring_private.h"

enum zustaende{Motor1, Motor2, Motor3, Sleep};
extern int zustand;

class IRControl {
private:
    IRrecv *irrecv;
    decode_results remoteValue;
public:
    IRControl(int RECV_PIN);
    virtual ~IRControl();
    void menu();
};

#endif /* IRCONTROL_H_ */
</code></pre>

<p>cpp-File:</p>

<pre><code>* IRControl.cpp
 *
 *  Created on: 04.04.2016
 *      Author: David
 */

#include "IRControl.h"

IRControl::IRControl(int RECV_PIN) {
    // TODO Auto-generated constructor stub
    irrecv = new IRrecv(RECV_PIN);
    pinMode(RECV_PIN , INPUT);
    irrecv-&gt;enableIRIn();
}

IRControl::~IRControl() {
    // TODO Auto-generated destructor stub
    delete irrecv;
}

void IRControl::menu() {
    if (irrecv-&gt;decode(&amp;remoteValue)) {
        //lReceived = remoteValue.value ;
        Serial.println(remoteValue.value);
        /*
        switch(remoteValue.value)
                {
                case button1:
                    zustand = Motor1;
                    //digitalWrite (LED1, HIGH); // for control
                    break;

                case button2:
                    zustand = Motor2;
                    //digitalWrite (LED2, HIGH);
                    break;
                case button3:
                    zustand = Motor3;
                    //digitalWrite (LED3, HIGH);
                    break;

                case button0:
                    zustand = Sleep;
                    break;

                default: break;
                }
                */
        irrecv-&gt;resume(); // Receive the next value
      }
}
</code></pre>

<p><strong>Where the problem could be</strong></p>

<p>I think there could be a problem with the <code>IRrecv *irrecv;</code>. But i'm not sure.</p>

<p>Thanks for your help</p>
 10794: <p>Please post the code where you call the library. In particular where do you make an instance of IRControl?</p>

<p>I am guessing you are doing it at global scope which means you are probably running into the <em>C++ static initialization order fiasco</em>.</p>

<p>What it is: <a href="http://www.parashift.com/c++-faq/static-init-order.html" rel="nofollow">http://www.parashift.com/c++-faq/static-init-order.html</a></p>

<p>How to prevent it: <a href="http://www.parashift.com/c++-faq/static-init-order-on-first-use.html" rel="nofollow">http://www.parashift.com/c++-faq/static-init-order-on-first-use.html</a></p>

<p>To prevent this, you should <strong>not</strong> be doing this in the class constructor:</p>

<pre><code>irrecv = new IRrecv(RECV_PIN);
pinMode(RECV_PIN , INPUT);
irrecv-&gt;enableIRIn();
</code></pre>

<p>Instead, make a <code>begin</code> function (like most Arduino classes do) and call that from <code>setup</code>.</p>
