Can someone explain millis

Hi.
Need someone who explain millis... but the way me, an Polish guy will understand.
Simply need a button that once pressed and hold more than 3 second will write sensor data to eeprom but if hold less than free second will use eeprom data to drive output.

I`m not asking for code. just need to know how to use millis, or anything that will count time.
thanks

millis () simply returns the number of milliseconds (1/1000 of a second) that have passed since the device was last reset.
A simple, human-scale way of thinking of it is the number of seconds since midnight.
As such, it can be used as a timestamp; at a very simple level a higher millis value will have occurred later than a lower millis value.
Subtracting the smaller from the larger will give the number of milliseconds that have elapsed between the two events.

Does make sense.
So it should go along with function "long" to get the correct amount of time since the button been pressed?
(millis()-long)==time elapsed since button pressed?

"long" is a datatype, like "int", not a function, so "millis() - long" is going to give you a compilation error.

"millis()" returns an "unsigned long" (32 bit, unsigned) value

unsigned long buttonOn = millis();
unsigned long buttonOff = millis();

if(buttonOn-buttonOff>3000)do something
if(buttonOn-buttonOff<3000)do not react

damn
will this work?

Well, in the example you gave, the values of "buttonOn" and "buttonOff" will almost certainly be the same.

Why don't you try it?
Play around, print some values, see how it goes.

Im just at work now and cannot plug my arduino to the local pc. Ill try at home and after i`ll post some results.
Thanks

Hi,

This is a very good thread to read from Robin 2

http://forum.arduino.cc/index.php?topic=223286.0

Its good to use things like unsigned long currentMillis

we use long to prevent overflow

AWOL:
millis () simply returns the number of milliseconds (1/1000 of a second) that have passed since the device was last reset.
A simple, human-scale way of thinking of it is the number of seconds since midnight.
As such, it can be used as a timestamp; at a very simple level a higher millis value will have occurred later than a lower millis value.
Subtracting the smaller from the larger will give the number of milliseconds that have elapsed between the two events.

I just had to pick my jaw back up after reading that last line because You made it.

Always always subtract the start time from the end (or current) time to get the elapsed time, same as a clock. If my start hour is 11 and my end hour is 2 then by unsigned base-12 math 2 - 11 = 3. Binary is another base and unsigned math works the same for the 32-bit unsigned long that millis() returns.

Rollover of millis() takes 49.7-some days.
If you use micros() instead of millis() then rollover takes a little over 90 minutes.
Do the always rule and rollover is not a problem. Same code handles all cases.

Mr.Dropsy -- there is no need to use long instead. All that does is break the algorithm.