A bifunctional fluorescent probe based on a carbazole-pyrimidine conjugate for Hg(2+) and Cu(2+) detection was designed and synthesized. Probe 3 exhibits red shifts in its absorption and fluorescence spectra with significant visual color changes in the presence of these ions. The detection limits of probe 3 for these metal ions were in the nanomolar range. The probe could also be useful as a solid optical sensor for Hg(2+) and Cu(2+).