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

IHE OUTPUI AI{D  BEADING TI{E  INPUT
            AO  COTTNOLLIIIG

                    LED EXERCISES:  COIITROLLING  THE  LIGHT  ElulTTll{G
                    DIODES  (LEDsl
                    We will leam about  contolling the output from a PIC by writing a series  of increas-
                    ingly complicaled  programs  that will  conlrcl the  ten-segment  LED bargraph  provided
                    on the LAB-Xl.In  these  exercises, we  are conrolling  the LEDS'  but fie control  strate
                    gies  developed  will apply  to any kind of"ON  OFF'devices  we  have connected  to the
                    LAB-X1 or to any  other device  we design.

                    I . Light the eight LEDS on the righl one al a time till they are a  lit'  and then turn then
                      OFF  one at a  time. Time delay  betwe€n actions  is to be one-tenth  of a second  (exactly)
                    2, Modify the  preceding program so the delay  time is conlrolled  by lhe top  most  poten-
                      tiometer  on lhe  LAB-XI. The  time is to vary  from 10  milliseconds to  200 millisec-
                      onds  inclusive,  no less, no more.
                    3. Write a  pr  ogram that wi ll vary the  glow or the rjghtmost  LED from fully OFF  to lully
                      ON once  a second. Program  the sccond  LED to go  dark  dnd bdghi exacdy I 80  degrees
                      out of phase  with the  first LED so that as one LED is gelting brighter,  the other  LED
                      is getting  diDmer and  vice versa.
                    4, Write a  program  that flashes  ihe lbur leftmost LEDS ON and OFF  every 0.25 seconds
                      and  cycies the  four LEDS on the right lhrough  a bright/dim cycle  every two seconds
                    5, Write  a  program that flashes the  first LED ten  times a second,  flashes  the second  one
                      nlne  rime.  a.econd.  rnd n,1.1'e.  lhird  I fD  $hene\er borh LLDs  r-re on ar  lhe
                                                  rhe
                      same  time. Display how many times  the third LED has blinked on the LCD display.
                      (Timing can be approximate  but  has lo have a common  divider  so the third  LED will
                      give  the  beat liequency.)

                    LIOUID CHII|STAL  DISPLAY  EXERCISES!  COI{TROLLING
                    IHE  LIOUID  CRYSTAL  DISPLAY  (LGDI
                                 of tbe  memory locations  used by the LCD have aheady beer  fixed' as
                    The addresses
                    has the  instruotion set  we use to write to the LCD  The description  of the Hitachj
                    tID4,l780U  (LCD-II)  controller  instmction  sel as weil as ils electronic  characteristics
                    are  provided in the dala file for the display.  Here, wc will  list only the codes that apply
                    to our immediate  use of the  devioe.
                      Two types of commands can  be sent to the  display: the  contlol codes  and the sel  of
                    actual chamc€rs  to be  displayed.  Both uppelcase  and lowerca-se  characters  are suppofied'
                    as are a  number of special  altd  graphic  chaJacters  The contro]  codes allow you to con-
                    trol the display  and set the  position  ofthe cursor. and  soon. Each  control code  must be
                    preceded  by decimal254  orHer $FE.  (The  oonfol]er  also supports  the display  ofa set
                    of Japanese  characters  that are  not oI intetest  to us  )
                       Command  codes lor the  following aclions  arc  provided  along  with others. Go  to thc
                    datasheel for the conlroller  to find out  what all ihese  command codes  ale

                       Clear the LCD
                       Retum  home
   85   86   87   88   89   90   91   92   93   94   95