Page 84 - Making PIC Microcontroller Instruments and Controllers
P. 84
74 CO 'NOLLII{G THE OUTPUIATD NEADNG THE II{PUT
the keyboard rows and columns
*I$iilaii&ru: Beading the keyboard (Reading
and show key n!mber) (Contlnued)
FOR AI-PHA = 1 tO 4 need to look at 4 rows
IF {POREB & SFO)<>gFO IHEN
one of rhe bits in
84 Lo B7 chanses we; imnedialely
have to slore the vafue of PORTB
BUIFER =PORIIB
GOSUB SEOWKEYPRESS
ELSE
E![D1F
PORIB= PORTB << 1 nove bits lef! one pLace for
PORfB= PORIB + 1 put 1 back in LSBit, the right bit
IIfl(T AI.PIIA
GOEO I.OOP
SSOWKEYPIESS I
BI'FFER - BUFFER ^ %11111111 flips all lhe bits in the buffer
print rhe f,rst Line
\ROW=', (BLFFER & 90F),"
LCDOIII SFE, f80, BIN4
COn=/, BIN4 BITFFER >>4
COtUldN= (NCD BUASER) -4 ; caLculale coLm
ROw=riICD (BI'FFER &$0F) ; calculale row
SWIICE=( (ROw-l) * 4) +COIIJ!4N ; calculate swiLch nunlcer
; print the second line
\ROw=,, \
LCDOUf SFE, SCo? DEC ROW, COL-Z, DEC COLUMN,
\ g$t=/, DEc swrTcn, \ \
RETURN
END
and
Read One Potentiometer Display lts
8-Bit Value on LCD in Binary, Hex, and
Decimal Notation, also Impress the
A detailed discussion ofA to-D conversions is covered in tlte chapter, which is
devoted to the construction ol a digital thermometer insirument based on this
capability.
As mentioned before, the potentiometers are read by dividing the voltage adoss a poten-
tiometer into 256 pats and seeing which of the 256 divisions match the position of the