How to fade an LED up and down without using delay

A thing to remember:

int has a range of -32,768 to 32,767.
32767 milliseconds = 32 seconds.

Meaning: After 32 seconds, your

lastTimeItHappened = millis()

will behave strange

ALLWAYS use the type long or even better unsigned long when you work with millis() that way.

unsigned long has a range of 0 to 4,294,967,295 giving you
about 50 days of runtime before things get strange!

Good luck
C