Transmembrane receptors allow a cell to communicate with its environment in response to a variety of input signals. These can be changes in the concentration of ligands (e.g. hormones or neurotransmitters), temperature, pressure (e.g. acoustic waves or touch), transmembrane potential, or light intensity. Many important receptors have now been characterized in atomic detail and our understanding of their functional properties has markedly increased in recent years. As a consequence, these sophisticated molecular machines can be reprogrammed to respond to unnatural input signals. In this Review, we show how voltage-gated and ligand-gated ion channels can be endowed with synthetic photoswitches, and how the resulting artificial photoreceptors can be used to optically control neurons with exceptional temporal and spatial precision. They work well in animals and might find applications in the restoration of vision and the optical control of other sensations. The combination of synthetic photoswitches and receptor proteins contributes to the field of optogenetics and adds a new functional dimension to chemical genetics. As such, we propose to call it “optochemical genetics”.