Page 291 - Making PIC Microcontroller Instruments and Controllers
P. 291

PBOJECT 6   2e1



                  Sre              Flnal segment to make a finished  program-ihe  touch  panel
                   (Continuecl)


                       EIID  SEI.ECT
                     CASE  EI.SE
                   END  SE'.ECT
                    ;The  following   segmenr   of  code  uses  lhe   lwo   r'time   counters"   to
                    ;turn   the  two  LEDS  on
                    ;and  off  as  specined  by  lhe  fasrer/slower   buttons.   It  counts  each
                    ; Elrnrng   sequence
                    ; independentty   and  lurns   lhe  related   LED  on  and  off.
                    lF  LCD  I=ACTIVE   IIHEN
                      IF  STAI-I=BLINR   THEN
                       AI,PEA=AJ.PI'A   +1      i
                       IF  lJrPEA>=!   0  THEN   ;
                         AIPEA=o                i
                         TOGCI.A  I,CD.ONE
                       ENDIF
                     ENDIF
                    ENDIF
                    IF  LCD,2  EACTIVE   THEIiI
                      IF  STAI-2  EBLINK   THEDI
                       BEIA=BEIIA   +1          ;
                        IF  BEIA>=|!IMl   TXEN
                         BEIA=0
                         TOGSI.E  LCD_TWO
                       ENDIF
                      ENDIF
                    ENDIF
                    RETURN

                    PAITSER!                    ;  pause   to  de  bounce,   long
                      aOR  x=1  TO  300
                      PAUSE  1
                      NEK![  X
                    REIIURI|

                    PAusERl.                    ;  pause   to  de-bounce,   short
                      FOR  X=1  TO  50          ,
                      PAUSE  1                  i
                      NEXT  X                   ;
                    REIURN                      i
                    END                         i


                   EXERCISE
                   Modify  the hardware and the Prcgram 20.1 so tho four columns  are detected on lines
                   B4 to B7, and then use the intenupt capability of these four lines to imprcve the per-
                   formance of this program  by mating its operation crisper
   286   287   288   289   290   291   292   293   294   295   296