The lowest frequency is 78 Hz, the highest one is 4652 Hz. For the mathematically inclined this means that Analog to Digital conversion takes 180 uS for zero volts and 7720 uS for 5 volts.
Well, almost, it would be nice if we could actually change the frequency, so we'll also need to add another variable resistor:
PIC_ADC_read_low_res(0, resist)
delay_20us(resist)
if ! wissel then
pin_d1 = true
wissel = true
else
pin_d1 = false
wissel = false
end if
To determine the actual frequency the time it takes to measure A/D and to process the other statements has to be taken into account. Rather than bother ourselves trying to calculate this we will simply measure the frequencies with a frequency counter. Lazy bones ofcourse
http://members.home.nl/b.vandam/lonely/pagina43.html