int Read_T(void);
void alarm (void);
main()
{
TRISB = 0xF0;
CMCON = 0x07;
while(1)
{
while(Read_T()<10)
{
alarm();
}
}
}
int Read_T(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<200;i++)
{
PORTB.F0=1;
Delay_us(200);
PORTB.F0=0;
Delay_us(200);
}
PORTB.F1=0;
for (i=0;i<200;i++)
{
PORTB.F0;
Delay_us(200);
}
}
No comments:
Post a Comment