Here's a fun moth fact for you.
Moths respond more to certain wavelengths, especially shorter wavelengths going into the UV spectrum. In addition, different moths are more attracted to different wavelengths (i.e. shorter wavelengths are significantly more attractive to noctuids).
It's thought that the reason moths are attracted to lights is because they interfere with the moths' navigational senses; nocturnal species are believed to use moonlight to navigate, so artificial light sources will confuse them. Once near the light, they may be temporarily blinded or confused by the sudden bright light, and as such, they'll be less inclined to leave.