Out of memory, how to reduce this program's size

Not best solution bit it works

Well, except he's here because -something- isn't working.

Shouldn't lastsecond be an unsigned long? That's what millis() is. Probably not what is causing the problem you are having.