What is Millis?


What kind of function does this program do?

if ((millis() - time) > debounce

Allows for periodic checking to see if it is time to do something.
In this case, if a switch debounce period has expired.

Look at the Blink Without Delay example in the IDE.


The millis() function returns the number of milliseconds since your Arduino was reset or powered up.

In your example there must also have been code to place a value in the variable "time"


It is looking for the amount of time since 'time' was last saved and testing if it is more than 'debounce'.

Google "switch debounce". This is probably being used to make sure the switch is really closed (or opened) on purpose and to make sure that when the user closes a switch it only counts 1 switch event, even if there is some bouncing of the contact resulting in the signal going high and low several times when the user only intended one switch press.

This line ignores a switch change until the input signal has been in the same state for a long enough period of time that we know it is real.