Sample and hold


i am new to this forum have resiliently bought a arduino.
And as my first project i had tried to write a sample and hold code, but i have failed

Basically i would like to sample a value from a POT every time i hold down a button,
i had found something similar here Arduino Forum but i am a newbie so i don`t understand it
so i beg for some help here,


If you post your code, it makes it easier for us to help you.

i have no code but i have tried to make one, but as a said i am new to this programming langue so i wonder i some of you can come upp with a code.

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.

Ok i will try, thanks