The electrode potential of a photochromic spiropyran-modified Au electrode could be reversibly modulated by UV/visible light irradiation in the presence of Zn2+, and a new molecular switch and an "AND" logic gate based on this electronic transduction of the optical signals were established.