The number of eyes that an insect has varies from insect to insect. For example, the grasshopper has two compound eyes and three simple eyes, while a common housefly has a pair of complex eyes, each of which has as many as 6,000 simple eyes inside.
Compound eyes are unique because they are made from repeating units known as ommatidia. Each ommatidia works as a separate visual receptor and consists of a lens, a cone, visual cells and pigment cells. Together, the ommatidia work to provide a mosaic image. The fewer the ommatidia, the grainier and coarser the image. The compound eye of the insect makes it adept at detecting motion, which is the reason that it is so hard to sneak up on a fly with a fly swatter.