arduino codes to measure speed of a falling simulated raindrop

I have decided to use two IR led (38 kHz Pulse Generator with a 555 Timer) with the circuit as shown in this link Pulsed IR Sensor . Also i'll be using 2 ir receivers( http://www.engineersgarage.com/sites/default/files/TSOP1738.pdf ).

Next step would be to calculate the time for the drop to calculate the time for the drop to travel from IR led 1 to IR led 2. So, i guess signal would be cut as the drop pass through the ir beam. I would like to know from the output of the receiver how to connect it to the arduino uno and what code would be suitable for this purpose? Thanks in advance.
//Speedometer
/*This program computes the speed of a projectile using photo interrupter LED/transistor pairs,
and displays the result on the serial monitor.
The time elapsed between activation of two successive photo interrupters is measured.
The distance between the respective sensors is divided by the time elapsed.
The resulting value corresponds to the average speed during the interval between the two sensors.
There are two photo interrupter pairs used to obtain average speed data.


|Sensor| |Sensor |
| 1 | | 2 |

|<-----gateDist-------->|
*/

//Constants
const int gate1Pin = 2; //assigns the first photointerrupter to digital I/O pin 2
const int gate2Pin = 3; //assigns the second photointerrupter to digital I/O pin 3

//Variables
long startTime;
long travelTime;
float gateDist = 0.03; //This is the spacing between gates in meters. The default
//is 0.03 m or 3 cm. This value should be adjusted accordingly
//if the gates are spaced closer or further apart. For example, for
//a gate spacing of 2.5 cm spacing you would need to
//replace 0.03 with 0.025, etc. for accurate result.
float travelSpeed = 0; //the speed of traversing the two gates

void setup(){
pinMode(gate1Pin, INPUT);
pinMode(gate2Pin, INPUT);
Serial.begin(19200);
}

void loop(){
if(digitalRead(gate1Pin)<1)
{
startTime = micros();
while(digitalRead(gate2Pin)>0);
travelTime = micros() - startTime;
travelSpeed = gateDist / travelTime * 100000000
;
Serial.print("The last velocity was ");
Serial.print(travelSpeed,0);
Serial.print(" centimeters per second");
}
}
Guys let me know what u think about this program. I am assuming that it will work just fine for my project.
Also, let me know how i could enhance it to have better results.
thanks

I don't know whether a falling water droplet will reliably break an IR beam, so you might want to test that before you get too far.

Since you're only using the beam to detect the droplet, rather than modulating it to carry information, why are you pulsing it?

I was reading a post yesterday I think in which someone was trying to do the same thing (or maybe it was you somewhere else)?

They were having issues just as PeterH said, being unable to interrupt the beam with a water drop.

Once you get that figured out, I made a post here yesterday answering someones question about Ir receivers.

http://arduino.cc/forum/index.php/topic,148554.0.html

Basically, you feed the Vs pin on your detector with your voltage supply (5V from arduino), ground the ground pin, and then read the third pin with a digitalRead in your arduino sketch using any of the digital pins on the board. Looking at your data sheet, it looks like the OUT pin should read high when no modulated IR light is detected, and low when it is (the transistor should be getting a current from the detector).

If you read my other post, make sure to take not that the leads on the detector he used are in a different order than yours. (though I doubt you can harm the detector by hooking it up backwards.... but I would avoid it since I may be wrong)

I'll be modulating the beam at 38kHz. The system has already been tested. However i'm having trouble in writing the codes as I relatively new to using arduino. Any idea on how to write the codes and any tips would be welcomed

rowin:
The system has already been tested.

Does this mean you've confirmed that the droplet breaks the beam?

I still don't understand why the beam is modulated. What's the reason for that?

PeterH:
I still don't understand why the beam is modulated. What's the reason for that?

Maybe I shouldn't interject, but a modulated beam scheme can be used more reliably in the presence of ambient light ("noise").

Yes the droplet will break the beam. From what i've understood from resources of the internet, the IR receiver i' ll be using would only be sensitive to a specific frequency of 38kHz. So ambient light would not be affecting the receiver and there would be change only when this specific beam is cut by the droplet. I've posted the link of the ir receiver i'll be using. I would be grateful if you could suggest better settings/devices that would help.

That sounds plausible.

It seems to me that you will need to write some code to monitor the IR receiver input and lock on to the 38Kz signal, and then have some pretty quick way to detect loss of lock. And you'll need to play with the receiving code and the 'loss of lock' criteria to try to eliminate false positive or false negative triggers. If it's a nice clean signal you could just average the signal over the short term to smooth out frequency noise, average over a longer term to get rid of low frequency noise and identify the mean value, and detect when the smoothed signal was sufficiently above and below that mean to be deemed high and low, and then look for transitions at about the right interval; if you miss several expected transitions in succession, you could deem that a loss of signal. But that assumes a fairly well behaved signal and you might not be so lucky.

Ready for the buzzkill? From the TSOP1738 datasheet:

After each burst which is between 10 cycles and 70
cycles a gap time of at least 14 cycles is neccessary

TSOP1738 doesn't allow you to create a continuous beam; it will reject it after 70 pulses. You need a "fixed gain" (Vishay TSSP4038 et. al.) receiver to create a continuous beam. Might be worth mentioning that those fixed gain receivers are a bit hard to come get your hands on.

Also see how the Camera Axe implements a projectile sensor:
http://www.cameraaxe.com/wiki/index.php?title=Sensors#Projectile_Sensor