Like all insects, flies have brains. Their brains consist of the protocerebrum, deutocerebrum and tritocerebrum. The fly's protocerebrum controls its compound eyes and its ocelli, which are a trio of simple eyes found between the compound eyes. Ocelli help the fly navigate.
The deutocerebrum controls the animal's antennae, and the tritocerebrum controls part of the fly's mouth parts. The tritocerebrum also allows the brain to communicate with the rest of the fly's central nervous system.
Other bundles of nerves, beneath the fly's brain, control the animal's other mouthparts, wings and flight muscles, as well as the digestive, reproductive and sensory organs.