Help with time calculation code?

So im making this speedometer, im almost done with the hardware ,my idea is to cut a connection between a ir led and phototransistor once per revolution, my question is how can i write a code to calculate the time between each i can use the formula S=D/T ???

Each time a break is detected, you need to record the time (currTime = xx()), where xx is either millis() or micros() (depending on the time between breaks), after saving the current time as the previous time (prevTime = currTime).

Then, time between pulses is T = currTime - prevTime.

You’ll need to measure D so you can compute S.

also im a beginner at do i need to use interrupts? pls can u write a basic small example pls.. thankyou!

so do i need to use interrupts?

That depends on what else the Arduino is doing, and how long between breaks. If the thing breaking the beam breaks it once a week, then, no you don't need interrupts. If the thing breaks the beam every 10 nanoseconds, your hosed.

pls can u write a basic small example pls..

can u learn to spell and capitalize words correctly?

Also can i use pulsein function?? ,the beam breaks in a few seconds...Can pulseIn be used to measure time of a variable changing form HIGH to LOW?

The pulseIn function probably does not do what you want/think it does.

It times how long a pulse is HIGH or LOW. If called with a value of HIGH, it waits for the pin to transition to LOW, records the time, then waits for the pin to go LOW, and records the time again. It then returns the difference between those two times. It does something similar when called with LOW, waiting for the pin to go HIGH then timing until it goes LOW.

the beam breaks in a few seconds

An eternity to the Arduino. Polling would be sufficient. If, of course, the Arduino is doing 247 other things.