Page 341 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 341

Amphibionics 07  3/24/03  9:13 AM  Page 320
                                                       Amphibionics
                      PROGRAM 7.9
                      remote-sonar.bas
                                          trisb = %00000001
                      program listing     ' PortB set as outputs. pin 0 input.
                      (continued)
                                          '------------------------------------------------------------------------------------------------------------------------------
                                          ' initialize variables
                                          include "modedefs.bas"
                                          rx_baud            CON N2400
                                          rxmit                 VAR PORTB.0
                                          enable_right     VAR PORTB.1
                                          forward_right    VAR PORTB.2
                                          reverse_right    VAR PORTB.3
                                          enable_left       VAR PORTB.4
                                          reverse_left      VAR PORTB.5
                                          forward_left      VAR PORTB.6
                                          trigger               VAR PORTA.0
                                          echo                 VAR PORTA.1
                                          piezo                VAR PORTA.3
                                          control              VAR BYTE
                                          temp                 VAR BYTE
                                          dist_raw            VAR WORD
                                          dist_inch           VAR WORD
                                          conv_inch         CON 15
                                          low enable_left
                                          low forward_left
                                          low reverse_left

                                          low enable_right
                                          low forward_right
                                          low reverse_right


                                          SOUND PIEZO,[115,10,50,10]

                                          start:

                                          serin rxmit,rx_baud,["Z"],control


                      320
   336   337   338   339   340   341   342   343   344   345   346