Thanks for the comments:
I've tried using the LDR in series with a 10K pot between 5v and GND, connecting GPOI.0 to the junction between them and still can't get anything meaningful for the value of the variable that stores the ADC readings.
I've corrected the code thus:
Code:ASM __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF endasm ' Hardware configuration ' ====================== TRISIO = %001111 ADCON0 = %10000001 ANSEL = %00110011 DEFINE ADC_BITS 8 DEFINE ADC_SAMPLEUS 50 CMCON0=7 Motor1 var GPIO.4 Motor2 var GPIO.5 ADChannel0 var byte GPIO = 0 ' clear all output Pause 50 ' internal oscillator settle time main: low Motor1 low Motor2 adcin 0,adchannel0 ' Read AN0 If adchannel0 >10 then high Motor1 Low Motor2 pause 5000 low Motor1 low Motor2 endif goto main




Bookmarks