Methods of detecting components of interest, e.g., nucleic acids and sugars, are provided. The methods comprise contacting one or more nanowires comprising a functional group with a sample containing the component or components of interest. In one embodiment, the functional group comprises a hairpin oligonucleotide, e.g., a hairpin that changes conformation upon binding the component of interest, e.g., a nucleic acid. The change in conformation produces a change in charge that is detected. In another embodiment, the functional group comprises an enzyme, e.g., glucose oxidase, which produces a change in pH when glucose is present in a sample.