First off the ADC needs setup, here is an example.
http://www.microengineeringlabs.com/...pbp/adcin8.bas
Voltage...
Lets say you are using an 8 bit ADC. Voltage reference is VDD and the PIC is running at 5 volts.
There are 256 steps, 0 to 255.
The ADC value of 255 will represent full scale and be 5 volts.
The ADC value of 127 will represent 2.5 volts.
Looking for 3 volts? The ADC vale would be 153.
Want more accuracy? The 10 bit ADC has 1024 steps.
Your loop. After the set up.
Code:
loop:
ADCIN 0, adval ' Read channel 0 to adval
IF adval <= 153 then gosub Xlabel '3 volt and less trigger
IF adval = 255 then gosub Zlabel '5 volt trigger
Pause 100 ' Wait .1 second
Goto loop ' Do it forever
Xlabel:
'Do something
Return
Zlabel:
'Do someting
Return
End
That is the basics.
Bookmarks