I am working on a home project in which I need a cheap voltage sensor. I need an 8051 to monitor the voltage that I am getting from the wall. All I want to do is monitor whether the voltage is on or off. If it is on then I need to switch to a back up power source. I guess I could use a current sensor if need be. Thanks
If it is an DC Voltage, I would take an voltage divider by resistors. It should flow a current of a few mA. Then the divider isn't too sensitiv. You can protect the Port by an Shottkey Diod, if there could by spikes on the monitored voltage.