Help making an accelometer

I’m a beginner and I’m trying to make a accelometer with an arduino.

PLAN
There will me a moving cart that has 2 notches 4cm/1.575’’(inches) appart and the notches are are also 4cm wide and a sensor measuring how long each noch needs to pass through ths sensors.

[HOW WILL IT CALCULATE THE ACCELERATION]
By psychic

  V2 - V1              

a=-------------
…----- t

V2= end speed
V1=start speed
t=time
a=acceleration

% HOW IT CALCULATES V1 AND V2 %
1st notch passes and it measures its time and devides it with 4 and gets V1
2nd notch passes and it mesures its time and devides it with 4 and gets V2

% HOW IT GETS t %
t= how long it takes the whole thing to get thrugh the sensors

///////////////////// THIS IS MY CHALANGE AND YOURS LETS MAKE IT TOGETHER WORK \\\\\\
\\\\\\\\\\\ IF I DID ANYTHING WRONG OR DOESENT MACH CONTACT ME PLEASE ///////////

dear,

you can make it with two IR,
by calculating the time between 2 IR.

Hi,
Thank you for your reply/idea,
but how do iget the code an to make it calculate.
After the hardware there is a bigger hill the code.