code
int Read_VR1(void);
int Read_VR2(void);
main()
{
TRISB = 0xF0;
CMCON = 0x07;
while (1)
{
PORTB.F0=1;
while (Read_VR1()<5)
{
while (Read_VR2()<5)
{
PORTB.F0 = 0;
}
}
}
}
int Read_VR1(void)
{
int i;
i =0;
TRISA = 0xF0;
PORTA.F0 = 1;
PORTA.F1 = 0;
Delay_ms(10);
TRISA = 0xF1;
while( PORTA.F0 == 1)
{
i++;
}
i = i/10;
return i ;
}
int Read_VR2(void)
{
int i;
i =0;
TRISA = 0xF0;
PORTA.F0 = 0;
PORTA.F1 = 1;
Delay_ms(10);
TRISA = 0xF2;
while( PORTA.F1 == 1)
{
i++;
}
i = i/10;
return i ;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น