Time counter for pushed button.

Hi All, i am trying write a program that counting how much seconds the button was pushed? Which command i need to use for counting time?


You might try the PulseIn command http://www.arduino.cc/en/Reference/PulseIn, but be aware that a button may bounce See http://www.arduino.cc/en/Tutorial/Debounce

You can also use the millis() command to note the time the button was pressed and then released. Then the difference in the two readings is the number of milliseconds the button was held down. Unlike the pulseIn() you don't stop the code execution while the button is down.