Hi Al,
I've modded the code so I can see what's going on.
Code:
ASM
__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF
endasm
TRISIO = %001111
ADCON0 = %10000001
ANSEL = %00110011
DEFINE ADC_BITS 8
DEFINE ADC_SAMPLEUS 50
DEFINE ADC_CLOCK 2
CMCON0=7
Tx var GPIO.5
ADChannel0 var byte
GPIO = 0 ' clear all output
Pause 50 ' internal oscillator settle time
main:
adcin 0,adchannel0 ' Read AN0
Serout2 Tx,84, ["val: ",#adchannel0,10]
pause 5000
goto main
The divider made up as the LDR between +5v and GPOI.0, and the 18K between GPIO.0 and GND.
Compiled the code and loaded it to the chip. Opening the serial tool in Micro-studio I get a value of 1 when the LRD is in ambient light or covered and 2 with the torch shone directly on it.
Ideas ??
Bookmarks