complete my first project

hey guys
i'm working on a small project since last 1 week.
but i'm little bit confused in Arduino sketch
i'm using an analog pin as an input and a digital pin as an output
my task is that........
when analog pin (A0 to A7 in Arduino NANO) is less then 500 the timer is start and calculate the duration of that analog pin less then 500. simply i want to measure the time of an analog pin in state < 500.
let's say the time duration is "x"
then i want delay "x+1.5 sec"
and set a digital pin as an output high.
then delay for 1 sec.

when the second loop is started its again calculate the duration "x"
that's means
in every loop the "x" duration is not same.
...

i hope you will help me
thanks in advance

sorry for my bad English!!!

Please post your full sketch. If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it's ok to add it as an attachment.

When your code requires a library that's not included with the Arduino IDE please always post a link(using the chain link icon on the toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger(Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.