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

Amphibionics 07  3/24/03  9:13 AM  Page 314
                                                       Amphibionics
                      PROGRAM 7.7
                                          ' initialize variables
                      avoidance.bas program
                      listing (continued)  '------------------------------------------------------------------------------------------------------------------------------
                                          trigger                VAR PORTA.0
                                          echo                  VAR PORTA.1
                                          piezo                 VAR PORTA.3
                                          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
                                          dist_raw            VAR WORD
                                          dist_inch           VAR WORD
                                          conv_inch         CON 15
                                          turn                   VAR BYTE

                                          low enable_left
                                          low forward_left
                                          low reverse_left

                                          low enable_right
                                          low forward_right
                                          low reverse_right

                                          SOUND PIEZO,[115,10,50,10]
                                          turn = 0


                                          start:

                                          gosub sr_sonar

                                          if dist_inch < 12 then
                                            turn = turn + 1
                                            gosub backwards
                                            if turn.0 = 1 then
                                              gosub turn_left
                                            else


                      314
   330   331   332   333   334   335   336   337   338   339   340