A diarylethene bearing a triazole-linked rhodamine B unit was synthesized. Its fluorescent emission was significantly enhanced in the presence of protons or Cu due to transformation from the pirocyclic form to open-ring form. The fluorescence was quenched sequentially upon irradiation with 297 nm light based on the intramolecular fluorescence resonance energy transfer mechanism. In an acetonitrile: water binary solvent (1: 1 v/v), the compound showed significant fluorescent enhancement for Cu compared with a wide range of tested metal ions with a fast response and a limit of detection of 2.86 × 10 mol L . Using Cu and UV light as the chemical inputs, and fluorescence intensity at 597 nm as the output, a logic gate was developed at the molecular level. Moreover, the compound can be used with a high accuracy to detect Cu in a natural water sample.