Hell again all... seems like I get one thing fixed and something else goes wrong. I am having a problem with my ADC on the PIC16F877A. Here is the code that I am using:
Code:
DEFINE OSC 20
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 1
PAUSE 1000
LIGHT VAR WORD
ADCON1=%10000010
TRISA=%11111111
TRISB=%00000000
TRISD=%00000000
MAIN:
ADCIN 1, LIGHT
LIGHT.0=PORTD.6
LIGHT.1=PORTD.7
LIGHT.2=PORTB.0
LIGHT.3=PORTB.1
LIGHT.4=PORTB.2
LIGHT.5=PORTB.3
LIGHT.6=PORTB.4
LIGHT.7=PORTB.5
LIGHT.8=PORTB.6
LIGHT.9=PORTB.7
GOTO MAIN
END
This measures the voltage coming from a CDS Photocell circuit. I have Vcc to photocell to 10k resistor to ground. ADC is connected between the photocell and 10k resistor, so as the resistance of the photocell changes, as does the voltage. I can measure this with a meter but when I try to output to light up the corresponding LEDs it doesn't work right. Any help with this will be greatly appreciated.
Bookmarks