code
int Read_VR (void);
main()
{
int i,time;
TRISB = 0x00;
CMCON = 0x07;
while(1)
{
for(i=1;i<129;i=i*2)
{
PORTB = i;
time = Read_VR ()*2;
Vdelay_ms(time);
}
}
}
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 ;
}
int Read_VR (void);
main()
{
int i,time;
TRISB = 0x00;
CMCON = 0x07;
while(1)
{
for(i=1;i<129;i=i*2)
{
PORTB = i;
time = Read_VR ()*2;
Vdelay_ms(time);
}
}
}
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 ;
}
No comments:
Post a Comment