Several DNA templates with the sequence 5 0 -T n TAACCCCTAACCCCT-3 0 (n = 0, 15, 30, and 45) were used to prepare DNA template-silver nanoclusters (DNA-Ag NCs). The T n sequence acts as a recognition element for Hg 2+ , while the rest of the sequence acts as a template for DNA-Ag NCs. At pH 3.0, the fluorescence intensity of DNA-Ag NCs is enhanced by ATP, and the enhanced fluorescence is quenched by Hg 2+ . The length of polyT shows a slight effect on the sensitivity for the detection of Hg 2+ but almost no effect on the optical properties of DNA-Ag NCs. The fluorescence response of DNA-Ag NCs (T 15 -DNA-Ag NCs) vs. Hg 2+ concentration shows two linear ranges over 10-100 and 100-1000 nM, mainly because of the fluorescence quenching due to DNA conformational changes through T-Hg 2+ -T coordination and the formation of an amalgam with Ag NCs, respectively. The sensitivity of the T 15 -DNA-Ag NC probe was validated through the analysis of Hg 2+ in spiked pond water. Based on the switch-on and switch-off fluorescence properties of T 15 -DNA-Ag NCs, an IMPLICATION logic gate was fabricated using the concentrations of ATP and Hg 2+ as inputs and the fluorescence intensity at 585 nm as output.