Page 87 - Making PIC Microcontroller Instruments and Controllers
P. 87
Ifwe want to rcad all three pots, we have to activate their three lines and crcate vari_
ables to stote the three resuhs obrained. The modifications to progran
5.16 are shown
rn rlogram i.I /
l:lfrii.!ai|ii.i!!!!ar Display potentiometer settinss (Reading and disptaying
aI rhree
polenliomeiers
vatues in decimat tormat)
CI]E]AR
; define LCD connections
DEFINE OSC 4
DEFINE LCD DREC PORTD
DEFINE IJCD DBIT 4
DEFINE ITCD_RSREG PORTE
DEFINE LCD RSBIT O
DEFTDIE IJCD.EREG PORTE
DEFINE LCD_EBIT 1
rro$r PoRtE.2
LCD R/\|7 Line low {td)
PAUSE 500
wait .5 second for LCD srartup
rne next.J defines axe needed for
the ADCIN comand
DEFINE A.DC-BTTS 8 se! nunber of bits in result
DEFINE T.DC CIJOCT( 3
set inLernal clock source (i=rc)
DEFXNE ADC_SA!'FLSUS 50
set sanplinq riine in us
TRXSA = %11111111
ser PORTA to alt inpur
TRISD = %00000000
set all PoRTD liaes to outpurs
AncoNl = %00000110
PORTA and PORTE Lo digital
A2D Valueo vAR BytE
create A2D-vaLue to slore r.esult 1
A2D_Va1u61 VAR BYTE
create A2D Value to srore resulr 2
A2D VA1UE2 VAR BYTE
create A2D value to store resutt 3
LCDOUT SFE, 1
clear the display
IdAINI,oOP r ; maan progran toop
; cnec]. porentioneter vaLues
ADCTN 0, i2D VALttEo
; read chaanel 0 ro A2D-VatueO
ADCIN 1. A2D_VAIJUEI
; read channet 1 to AzD vatuel
aDctl{ 3, A2D VArruE2
; read channel 2 to A2D va1ue2
rrcDour $FE, 980. DEC A2D-VAIrUEo, " \,DEC A2D,VAIJnE1,' \
A2D_VArtrttE2, z \ ,DEC
PAUSE 10
GOFO UATNLOOF do it all forever
EIID