The capacity of some compounds to change in function of the pH was known since the sixteenth century. This effect was even known before the development of acid-base theory. Those are found in a wide range of plants like roses, cornflowers, primroses and violets. Robert Boyle was the first person to describe this effect, employing plant juices (in the forms of solution and impregnated paper).
Molecular switches are most commonly used as pH indicators, which are molecules with acidic or basic properties. Their acidic and basic forms have different colors. When an acid or a base is added, the equilibrium between the two forms is displaced.