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

PBOJECT  7   2s9


                                   single-polnt controller:  full program (rhis pfosram  runs  on rhe
                  iflliiiaL&gli*K
                    board that Jits on the box lrom All Elecircnics. See Figure  21.1 lot an illustration  )
                    \Continuecl)
                    IRTSA='600111111                    ;  se!  PORTA
                    !RISB=%00001000                     ;  set  PORTB
                    fRtSD=%00000000                     ;  set  PORTD
                    ERIS  =%00000000                    ;  set  PORTE
                    A.DCON1=%00000010                   ;  seL  analogl  pin  selections

                    PAUSE 5OO                           ;  Pause  to  start   uP  LcD
                                       'CLEAR"
                    T CDOIXD  $FE.  $01.                ;  display   Clear  nessage
                    PAUSE 500                           ;  Pause  to  see  nessage
                    LcDouI  $FE,  $01                   ;  clear   Lhe  screen
                    POR4a.2=O                           ;  grround  rhis
                    OPEION,REG.T=O                      ,  pu]l   all   PORTB inputs   high
                    nooP:                               ;  main  roop
                    alctN   0,  val,o                   ;  read  channel  0  potenLioneLer
                    ADctN  3,  vrl,1                    ;  read  channeL  3  lenp
                    vAt l=10*vA!1/5                     ;  caLculate   VALL
                    t CDOTX!  gFE,  S80.  "In!tP=,,  DEC3 Vl|'....  ;  dlsplay   infornation
                    T.CDOIXT  9m,$CO,'SE!=/,DEC3   VAtro  ;  display   infornalion
                    tF  VArl>=vAl,O  AND PORTB-3=1  'SEN  ,  conpare  to  selting
                       PORI[D-3=o                       ;  set  PoRTD.3=O
                    EI.SE
                      POBID.3-1                         ;  set   poRTD.3=I
                    ENDIF                               ;  end  decrsion
                    IF  PORTB.3=o FSEN                  ;  see  if  inhibit   is  on.
                       PORTD.2-o                        ;  sel  PoRTD.2=0
                    EIJSE
                        PORTD.z=l                       ;  se!  PORTD,2  =  0
                    ENDIF                               ;  end  decision
                    PAusE 10                            ;  delay  0.01  seconds
                    colo  IOOP                          ;  go  back  to  loop  and  repeat
                                                        ,  opera!ion
                    EIID                                ;  end  of  Proqlran
   293   294   295   296   297   298   299   300   301   302   303