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

PROJECT 6   249


                  rlL?titq!*nxelil  Finat sesment to make a finished  program-the  louch  panel
                   (Continued)
                     rF  PoRTB.3=1  IHEN  col=4  ;  check  pholo  for  coL  4  and  save  if  is  I
                     PORTC=%11111110             ;  turn  on  colm
                     PAUSE 2
                       IF  PORTB.4-1   'HEN  ROW=I    ;  check  photo  for  row  1  and  sawe
                                                      ;  i f i s l
                       PORTC=%11110111
                     PAUSE  2                     pause  needed  for  LED  to  react
                     IF  PORTB.s-1   IIIEN  ROW=2  check  photo  for  row  2  and  save  if

                       PORTC=?11111111             turn  everylhing   off
                    F.ETURN

                    DISPITAY:                      shov  setection   and  PoRTB and  c
                    LCDOIIT  SFE,  $80,r'R-lrDECl   ROW  'z  C=/'DECl  COIJ,/  D-l,DEC3  Tlldo,/-
                    D=z,DEC3  TIM1
                                       .B".               \
                    LCDOs:r  sFE,  $C0,     BINS  PORIIA,   Cz,  BrNS  POREC
                    RITI'RN
                    DO_IT:                        r o L . i - e  e r a . ! . e s  6 r _ r e .  o _  c e  e c ! i o , s
                    SELECT  CASE  ROW              f,rs!  look  a!  Lhe  rows
                     CASE  1                       ROW 1
                       SEI,ECT  CASE  COI,         look  a!  lhe  coLms
                         CASE  1
                           IF  t CD_ONE=I  THEN    if  LcD  in  oN
                             LCD_ONE=0
                             ICD_1-  INACEtItE     set  i!  as  inactive
                           EIJSE
                             L C D _ 1 = A C t 1
                             LCD_ONE-l
                                                                ' s
                             STAT_1=GI,oW          l o m o n o e (  t  q l o w ' r s  r o  b l - n r ' _ q
                             TIu0=10               reset  tine  !o  10  count
                           EDIDIF                  end  of  conpailson
                           GOSI'B  PAI'SER         pause  !o  de-bounce

                         CASE  2
                           rF  LCD-l=acTrvE   I'IIEN   ,  react   only   if   lhe  LED  is  on
                             IF  STAT_1=GIrOW THEN     ;  if   it   is  gLovinq
                               STAT,1-BIJIIiIK   ;  turn   lt   to  blinkiner
                             ELSE                ;  else
                               STAT-I-G'JOW      ;  turn   it   to  glot
                               I,cD_OliIE=1      ;  turn   il   on
                             ENDIF               ;  end  of  conparison
                             Gostt3  PAUaEB      ;  pause  to  de-bounce
                           ETIDIF                ;  end  of  conparrson
   284   285   286   287   288   289   290   291   292   293   294