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

Amphibionics 05  3/24/03  8:44 AM  Page 182
                                              endif
                      PROGRAM 5.5
                      serpentronic.bas
                      program listing     gosub infrared  Amphibionics
                      (continued)
                                             if object_detect = 1 then
                                               high led_left
                                               high led_right
                                               Sound piezo,[100,4,90,2]
                                               servo1 = 180
                                               gosub servo
                                               servo1 = 120
                                               gosub servo
                                               turn_count = turn_count + 1
                                                 if turn_count.0 = 1 then
                                                  gosub slide_right
                                                 else
                                                  gosub slide_left
                                                 endif

                                             endif

                                               low led_left
                                               low led_right

                                          gosub forward

                                          goto start


                                          'Subroutines start here

                                          '------------------------------------------------------------------------------------------------------------------------------
                                          ' slither forward routine in a sine wave pattern


                                          forward:
                                            servo1 = 157
                                            servo2 = 210
                                            servo3 = 143
                                            servo4 = 100


                      182
   198   199   200   201   202   203   204   205   206   207   208