fotocellule e arduino

o provato a costruire delle fotocellule tipo cancello utilizzando un emettitore e ricevitore ad infrarossi 950nm il problema e che il sensore risente dellla luce ambientale del sole creando interferenze come fanno i cancelli elettrici ad non avere questi problemi?

Ciao, innanzi tutto il vetrino rossoscuro che tutti i sensori possiedono sono dei filtri i quali tagliano una buona parte della luce infrarossa di disturbo, poi l'elettronica preleva un campo di frequenze da X a Y

ciao

Usa un TSOPxx38 (ricevitore telecomando a infrarossi) e un emettitore IR a 38Khz.
Circuito: come A Multi-Protocol Infrared Remote Library for the Arduino
Il pin di uscita segnale 38kHz é il pin 11 e non puó essere modificato a causa uso del rispettivo timer.

#define RXB 14
#define TX 11 
boolean transmitting_IR; //transmission flag

void turn_off_IR () //spegne segnale 38kHz su pin 11.
{
  TCCR2A = 0; // Disconnect PWM
  TCCR2B = 0; // Stops the timer
  OCR2A = 0;  // No timer top
  digitalWrite(11, LOW);                // Ensure output is off  
  transmitting_IR = false;
}

void turn_on_IR ()  // accende segnale 38kHz su pin 11.
{
  //   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
  transmitting_IR = true;
}


void detectIR()
{
    digitalwrite(13, digitalRead(RXB));  
	// il LED su Pin 13 si accende quando il fascio luminoso della fotocellula non é interotta
}


void setup(){  
  pinMode(TX, OUTPUT);
  pinMode(RXB, INPUT);
  pinMode(13,OUTPUT);
  turn_on_IR();
  delay(100);
}

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

Ciao Uwe

molte grazie, il tsop2238 non sapevo neanche d'averlo, sarà la fortuna.