Why is it that I can only read on portA 2,3
Program that I used suggested that I use portA,0
Want an easy explenation on the adcon1 bits and there relationship between adcon and adcin
please
Patrick
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : P van Biljon *
'* Notice : Copyright (c) 2006 Ver:2.44 *
'* : All Rights Reserved *
'* Date : 2006/07/07 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
DEFINE LOADER_USED 1 ' If using bootloader to program pic
DEFINE LCD_DREG PORTB 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 4 'Define first pin of portc connected to LCD DC4
DEFINE LCD_RSREG PORTC 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 1 'Define Portc pin used for RS connection
DEFINE LCD_EREG PORTC 'Define PIC port used for E line of LCD
DEFINE LCD_EBIT 0 'Define PortC pin used for E connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.
define osc 4
define adc_bits 8
define adc_clock 1
define adc_sampleus 50
samples var word
sample var byte
temp var byte
samples = 0
samples1 var word
sample1 var byte
temp1 var byte
samples1 = 0
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = 2
pause 500
init:
samples = 0
samples1 = 0
gosub loop
gosub loop1
gosub loop2
goto init
loop:
for sample = 0 to 20
adcin 2 ,temp
samples= samples + temp
pause 100
next sample
temp = samples / 20
return
loop1:
for sample1 = 0 to 20
adcin 3 ,temp1
samples1= samples1 + temp1
pause 100
next sample1
temp1 = samples1 / 20
return
loop2:
lcdout $fe,1,"Temp is: " ,DEC(samples/10) ,".",dec2 samples," C"
lcdout $fe,$C0,"Temp is: " ,DEC(samples1/10) ,".",dec2 samples1," C"
goto init
end
Bookmarks