Insect taste systems detect a vast diversity of toxins, which are perceived as bitter. When a species adapts to a new environment, its taste system must adapt to detect new death threats. We deleted each of six commonly expressed bitter Gustatory receptor genes (Grs) from Drosophila melanogaster. We found that requirements for these Grs differed. In an individual neuron, the response to different tastants depended on different Grs. The response to an individual tastant depended on different Grs in different neurons. Surprisingly, responses to a tastant in a neuron were reduced by mutations of up to four Grs, suggesting that some taste receptors are Gr heteromers containing four different subunits. Deletions also produced some increased or novel responses, supporting a model of Gr-Gr inhibitory interactions. We then examined bitter coding in three other Drosophila species. We found major evolutionary shifts. One shift depended on the concerted activity of seven Grs. Our results show how the complex logic of bitter coding provides the capacity to detect innumerable hazards and the flexibility to adapt to new ones.