/ * Project name:
Detect low voltage
* Description:
When voltage is detected LED blinks
* Test configuration:
MCU: PIC12F629
Dev.Board: EasyPIC5
Oscillator: 04.0000 MHz, Internal
SW: mikroC PRO for PIC
*/
unsigned char i;
bit oldstate; // Old state flag
void main() {
OSCCAL = 0b11111100; // calibrate internal osilator 4 MHz
CMCON = 0b00000100; // CIN- analog, Internal VRef
TRISIO = 0b00000010; // gp2 = output
VRCON = 0b10101111; // sets Vref
do {
if (CMCON.cout == 1) // if cmcon.cout=1 blink a led, else set led off, if the voltage is higher them 3,125 V blink a led
{
gpio.F2 =1;
delay_ms(500);
gpio.F2 = 0;
delay_ms(500);
}
} while(1);
}