Fireflies glow due to a chemical reaction in a specialized organ within their body. Firefly lights differ between species and function in courtship, as a way for compatible insects to find one another.
Inside the light-producing organ of fireflies are the enzyme luciferase and the pigment luciferin. Luciferase and luciferin combine with calcium and the high-energy molecule adenosine triphosphate to begin the reaction. The addition of oxygen catalyzes the reaction and produces light. The glow of a firefly is known as bioluminescence, and is a cold light, meaning it does not produce heat.
The ability of the firefly to regulate its glow and produce a specific pattern of flashes is still a mystery to researchers. Scientists know that nitric oxide must be present in order for oxygen to enter the light-producing organ. Without nitric oxide, oxygen binds to mitochondria and does not enter the light organ. When available, nitric oxide binds to the mitochondria, giving oxygen nowhere to go but into the light organ. It could be the supply of oxygen or the insect's nervous system that controls the pattern.
Some species of firefly make their own bioluminescent enzymes, while others eat the self-sufficient species to obtain their enzymes. These fireflies mimic the flashes of their prey species as a lure.