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

Amphibionics 03  3/24/03  8:11 AM  Page 36
                                                       Amphibionics
                                          The source file name should (but is not required to) end with the
                                          extension .BAS. The text file that is created must be pure ASCII
                                          text. It must not contain any special codes that might be inserted
                                          by word processors for their own purposes. You are usually given
                                          the option of saving the file as pure DOS or ASCII text by most
                                          word processors.
                                          Program 3.1 provides a good first test for programming a PIC and
                                          for testing the frog robot controller board when it is built in Chapter
                                          4. You can type it in or download it from the author’s Web site
                                          www.thinkbotics.com, and follow the links for book software.

                                          The file is named frog-test.bas and is listed in Program 3.1. The
                                          BASIC source file should be created in or moved to the same direc-
                                          tory where the PBP.EXE file is located.


                      PROGRAM 3.1         '------------------------------------------------------------------------------------------------------------------------------
                                          '  Name      : Frog-test.bas
                      frog-test.bas program
                      listing             '  Compiler  : PicBasic Pro MicroEngineering Labs
                                          '  Notes      : Program to test the main controller
                                          '                : board by flashing LEDs, producing
                                          '                : sounds and slowly rotating the servos
                                          '------------------------------------------------------------------------------------------------------------------------------
                                          ' set porta to inputs
                                          trisa = %11111111
                                          ' set portb pins 2 & 3 to inputs
                                          trisb = %00001100
                                          '------------------------------------------------------------------------------------------------------------------------------
                                          ' initialize variables
                                          servo_pos_l   VAR BYTE
                                          servo_pos_r   VAR BYTE
                                          timer1            VAR BYTE
                                          timer2            VAR BYTE
                                          timer3            VAR BYTE
                                          temp1             VAR BYTE
                                          servo_r           VAR PORTB.5
                                          servo_l           VAR PORTB.6


                      36
   52   53   54   55   56   57   58   59   60   61   62