Problema con Barriera IR

Non stai spedendo nessun codice. Stai spedendo un segnale continuo rettangolare con la frequenza di 38kHz. Non c'é nessun codice da decodificare. Non Ti serve nessuna libreria IRremote.h. Il TSOP mette l' uscita a LOW quando riceve un segnale a 38kHz e va a HIGH
Il codice sottostante puó accendere e spegnere il segnale 38kHz sul pin 2.
Ciao Uwe

#define RXTSOP 3      //Pin TSOP 
#define TXIR 2        //LED IR
#define LED13 13      //LED on pin 13


//flag
boolean transmitting_IR; //transmission flag

// turn_off , turn_on, detect functions come as is from
// http://www.eng.utah.edu/~cs1410/Labs/lab09.html

void turn_off_IR ()
{
  // Instead of just adjusting the output on pin 11, this code also
  // turns off the timer controlling the PWM output on pin 11
  
  TCCR2A = 0;                                   // Disconnect PWM
  TCCR2B = 0;                                    // Stops the timer
  OCR2A = 0;                                      // No timer top
  digitalWrite(TXIR, LOW);                 // Ensure output is off
  
  transmitting_IR = false;
}

void turn_on_IR ()
{
  //   Set up Timer2 (which can be connected to pins 3 and 11)
  //   For full details, see:
  //   arduino.cc/en/Tutorial/SecretsOfArduinoPWM
  //   The syntax here has me baffled, but the patterns of usage
  //   are clear if you look at the ATMega328 diagrams.
  //   _BV appears to stand for 'bit value'
  //   Different bits need to be set to control each timer
  //   Refer to diagrams for clarity

  TCCR2A = _BV(WGM21) | _BV(COM2A0);      // This mode toggles output once per timer cycle
  TCCR2B = _BV(CS20);                                  // Do not scale the clock down - use 16 MHz timer rate.
  OCR2A = 210;                                              // Divide sys. clock by 210, 1/2 cycle = 76 khz, 1 cycle = 38 khz
  
  // Output pin 11 should now be emitting a 38 khz signal.
  
  transmitting_IR = true;
}

void detectIR()
{
    if(digitalRead(RXTSOP)
    {
    digitalWrite(LED13 ,LOW);
    }
    else
    {
    digitalWrite(LED13 ,HIGH);
    }
}

void setup()
{  
  pinMode(TXIR, OUTPUT);
  pinMode(RXTSOP, INPUT);
  turn_on_IR();
  delay(100);
}

void loop()
{
  detectIR();                        // search for IR
  delay(50);  
}