Herein, the fluorescent carbon dots (CDs) with blue emission were prepared by hydrothermal treatment using pineapple peel as a source of carbon. The as-prepared CDs exhibited turn-Off fluorescence behavior toward Hg 2+ and subsequent turn-On behavior for l-cysteine along with enhanced biocompatibility and negligible cytotoxicity for cell imaging. The practical applicability of carbon dots was used for the quantification of Hg 2+ in water. On the basis of the spectral characteristic changes, we have designed individual elementary logic operations such as NOT and IMP gates, by utilizing CD as probe and Hg 2+ and l-Cys as chemical inputs. We have also demonstrated the utility of this system in electronic security devices and as memory element, with the idea of the switching. Copyright © 2018 American Chemical Society.