Baby Orangutan voltage code request

I realize by using 1 - 3.7v/170mah LiPo battery that I am running under spec for the Baby Orangutan(mega168). I was wondering if anyone had an code examples of monitoring the voltage to indicate when the battery drops below a certain level. Right now I am powering two planetary geared pager motors and three IR detectors off the regulator. It works, but obviously gets quirky pretty quickly. I thought about setting the BODLEVEL, but was not sure how that would impact things. As you can tell I am new to this and muddling my way through. Any thoughts on coding or better power management are welcomed.



You need more than code to accomplish what you want: you need a reference voltage. Usually, the voltage regulator provides that reference, but once you’re under 5V, you’ll need something else. Also, the Orangutans have the analog reference pin on the ADC tied to the Vcc line, so you will have to put your reference on a regular ADC input. As you battery voltage drops, the ADC reading would rise, and once it’s at a certain point, you can decide the battery level is too low.

- Jan