This device turns my bedroom ceiling light on or off when I whistle a steady tone. It lets me turn on the light before getting up in the morning, to help myself wake up. It also lets me read in bed at night and then turn off the light without getting up. (The project was inspired when I read Atlas Shrugged a few months ago and couldn't put it down. I liked the vehement anti-socialist arguments and the fact that the ideal man in the book is a tall electrical engineer. Both things are true.) Some people might suggest that buying a bedside lamp would accomplish the same thing as this project, but I don't listen to those people. Also, this method lets me control a brighter light and costs slightly less.
Detecting a tone The device works by counting the number of "cycles per second" of the sound picked up by the microphone. It sends the voltage from a microphone into a voltage comparator. The comparator outputs a logic "1" whenever the voltage is above a reference voltage, and a "0" when it's lower. (The reference voltage comes from a potentiometer.) A PIC microcontroller counts the number of 0-to-1 transitions coming from the comparator and decides whether there is a steady tone in the right frequency range.
The way it decides that is kind of primitive, but it works fairly well: the PIC counts the number of 0-to-1 transitions in a 0.1-second time period and remembers it. Then, if the counts from the last four periods are within 10% of each other, and they're within a set frequency range, it decides that it's hearing a whistle and activates the relay. The idea is that it only responds to a whistle, and not other noises, because of the frequency range requirement and the requirement that the frequency is steady.