code
int Read_VR(void);
void alarm(void) ;
main()
{
TRISB = 0xF0;
CMCON = 0x07;
while(1)
{
while(Read_VR()<5)
{
alarm();
}
}
}
int Read_VR(void)
{
int i;
i =0;
TRISA = 0xF0;
PORTA.F0 = 1;
Delay_ms(10);
TRISA = 0xF1;
while(PORTA.F0 == 1)
{
i++;
}
i = i/10;
return i;
}
void alarm(void)
{
int i;
PORTB.F1 =1;
for( i=0;i<500;i++)
{
PORTB.F0 =1;
Delay_us(500);
PORTB.F0 =0;
Delay_us(500);
}
PORTB.F1 =0;
for( i=0;i<250;i++)
{
PORTB.F0 =0;
Delay_us(1000);
}
}
No comments:
Post a Comment