Page 195 - Build Your Own Quadcopter_ Power Up Your Designs with the Parallax Elev-8
P. 195

174     Bu il d  Y o ur  O w n  Q u a d c o p t e r


                             CON
                               _clkmode = xtal1 + pll16x
                               _xinfreq = 5_000_000

                               LCD_PIN = 19              ‘I selected this servo port for
                                                              convenience
                               LCD_BAUD = 19_200         ‘Ensure the LCD back-pack matches this
                                                                rate
                               LCD_LINES = 4

                             VAR
                               long  pulsewidth[4]

                             DAT
                               pins  LONG 14, 15, 16

                             OBJ
                               lcd        : “debug_lcd”
                               RX         : “RX”
                               servo      : “Servo32v6”
                               num        : “Simple_Numbers”



                             PUB Init
                               if lcd.init(LCD_PIN, LCD_BAUD, LCD_LINES)  ‘init returns True if

                                 lcd.cursor(0)                            ‘cursor set to off
                                 lcd.backLight(True)                      ‘turn on LCD backlight
                                                                              for easier character
                                                                                  display
                                 lcd.cls                                  ‘clear the LCD screen
                                 lcd.str(string(“RX Demo v0.1”))          ‘welcome banner
                                 waitcnt(clkfreq + cnt)                   ‘wait for 1 second

                               servo.start                                ‘start the servo
                                                                                  object

                               Rxinput

                             PUB RXinput  | i, pulse[4]

                               lcd.cls
                               RX.start(@pins,@pulseWidth)         ‘start three RX objects using
                                                            the pins array values. RX populates
                                                            the pulseWidth array with the data
   190   191   192   193   194   195   196   197   198   199   200