Sample and hold

so i wonder i some of you can come upp with a code.

You'll learn a lot more if you at least try. There is only one function for reading a digital pin state - digitalRead(). There are two functions for getting the time that the Arduino has been running - millis() or micros(), depending on what level of granularity you need.

There is only one function for reading an analog pin - analogRead().

Combining the calls in the proper order is not difficult. A couple of if statements is all that is needed.

So, try something yourself. If you make some attempt, we'll be happy to help you figure out what is not being done in the proper order/way, etc.

If you offer money, then we'd be more willing to do the work for you. As long as you don't try to pass it off as yours when you turn your homework in.