IR LED sensor

Hi!

I have been buildning an IR communication link between my arduino unos from scratch, but I've run in to a problem. I don't know if the sensor I am using is fast enough. The fastest reliable reaction I can get from it is about 3ms at a 10mm distance.

digitalWrite(dataPin,state);
delay(3);
Serial.print(analogRead(A0));
Serial.println(digitalRead(dataPin));
state = !state;

This is my sensor: Dropbox - Public - Simplify your life
When I was testing it in the beginning, I found that the higher resistance I used the more sensitive the sensor got. Right now it's using a 1.42MOhm resistor.

Is this setup good or really wrong? I've just been going by trial an error really :stuck_out_tongue:

The fastest reliable reaction I can get from it is about 3ms

delay(3);

?

Sorry if I wasn't clear enough.

const int dataOutPin = 7;
const int dataInPin = 6;
boolean state = LOW;
void setup(){
  Serial.begin(9600);
  pinMode(dataOutPin,OUTPUT);
  pinMode(dataInPin,INPUT);
}

void loop(){
  digitalWrite(dataOutPin,state);
  delay(3);
  Serial.print(analogRead(A0));
  Serial.print(" ");
  Serial.println(digitalRead(dataInPin));
  delay(500);
}

With this code the serial shows correct 1's and 0's. but with "delay(2)" instead the bits are not always correct.

I just wanted to know if my sensor is a good setup, or if there is a much better circuit?

Are you sure you're using a photodiode and not an LDR?