Light production in fireflies is due to a type of chemical reaction called bioluminescence. This process occurs in specialized light-emitting organs, usually on a firefly’s lower abdomen.
The enzyme luciferase acts on the luciferin, in the presence of magnesium ions, ATP, and oxygen to produce light.
Light in adult beetles was originally thought to be used for similar warning purposes, but now its primary purpose is thought to be used in mate selection. Fireflies are a classic example of an organism that uses bioluminescence for sexual selection.
They have a variety of ways to communicate with mates in courtships: steady glows, flashing, and the use of chemical signals unrelated to photic systems.
Tropical fireflies, in particular, in Southeast Asia, routinely synchronise their flashes among large groups. This phenomenon is explained as phase synchronization. Current hypotheses about the causes of this behavior involve diet, social interaction, and altitude.
Video via Science Friday..
Quoted text via Wikipedia.