I am new in electronic.. recently, i saw my friend's project with a interesting stuff - his digital compass with a lcd module that have a function to show the energy remained in the battery!! i wanna ask that, it functions as a battery detector... the main part to do so is in software or hardware? can anyone explain the principles ..? How can it operate?