George
- 5th November 2007, 03:31
For some reason I can't seem to get this working, have played around for a couple of hours now and still no joy - I know it'll be in my setup somewhere - just cant find that vital point.
Many thanks in advance for any input (I only know half of what I'm doing when I set up these registers)
@ DEVICE PIC16F676, XT_OSC, MCLR_OFF, PROTECT_OFF, BOD_ON, CPD_OFF
Define OSCCAL_1K 1
DEFINE OSC 4
DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 50
TRISA = %000000
TRISC = %101100
ADCON0 = %10000001
ADCON1 = %00010000
ANSEL = %10000000 'enable ch7 analog
VRCON = %10000000 ' A/D Voltage reference
CMCON = 7 'Disable comparitor
red var PortA.2
green var PortC.0
PDWN var PortC.1
DAT var PortC.2
pwr var PortC.4
Switch var PortC.5
batt var byte
timeset var byte
display var byte
timer var word
b0 var byte
b1 var bit
b2 var byte
b3 var word
clear
timeset = 1
PortA = 0
PortC = 0
Begin: 'start sequence
adcin 7,batt
red = 1 'turn red led on
if batt > 10 then green = 1 'turn green led on
if batt > 50 then red = 0 'turn red off
pause 500
goto begin
Many thanks in advance for any input (I only know half of what I'm doing when I set up these registers)
@ DEVICE PIC16F676, XT_OSC, MCLR_OFF, PROTECT_OFF, BOD_ON, CPD_OFF
Define OSCCAL_1K 1
DEFINE OSC 4
DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 50
TRISA = %000000
TRISC = %101100
ADCON0 = %10000001
ADCON1 = %00010000
ANSEL = %10000000 'enable ch7 analog
VRCON = %10000000 ' A/D Voltage reference
CMCON = 7 'Disable comparitor
red var PortA.2
green var PortC.0
PDWN var PortC.1
DAT var PortC.2
pwr var PortC.4
Switch var PortC.5
batt var byte
timeset var byte
display var byte
timer var word
b0 var byte
b1 var bit
b2 var byte
b3 var word
clear
timeset = 1
PortA = 0
PortC = 0
Begin: 'start sequence
adcin 7,batt
red = 1 'turn red led on
if batt > 10 then green = 1 'turn green led on
if batt > 50 then red = 0 'turn red off
pause 500
goto begin