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

Amphibionics 06  3/24/03  9:02 AM  Page 240
                                                       Amphibionics
                                          being connected to the middle connector of the limit switches (see
                                          Figure 6.42). Turn the power back on, and push the limit switch
                                          on the robots right side with your finger. The PIC should produce
                                          alternating high and low tones from the piezo speaker. Trigger the
                                          left switch with your finger. A steady pulsing tone should be heard.
                                          If  the  tones  being  produced  do  not  correspond  to  the  correct
                                          switch, then reverse connector JP4 (Figure 6.42).
                                          '------------------------------------------------------------------------------------------------------------------------------
                      PROGRAM 6.1
                                          '  Name      : croco-switch.bas
                      crocobot-switch.bas
                                          '  Compiler  : PicBasic Pro - MicroEngineering Labs
                      program listing
                                          '  Notes      : Program to test the leg limit switches
                                          '------------------------------------------------------------------------------------------------------------------------------

                                          ' PortA set as outputs. pins 0 and 1 inputs
                                          trisa = %00000011


                                          ' PortB set as outputs. pin 1 input.
                                          trisb = %00000001

                                          '------------------------------------------------------------------------------------------------------------------------------
                                          ' initialize variables

                                          include "modedefs.bas"

                                          limit_left        VAR PORTA.0
                                          limit_right      VAR PORTA.1
                                          piezo             VAR PORTA.3

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

                                          start:

                                          If limit_left = 1 then
                                            SOUND PIEZO,[100,10]
                                            pause 20
                                          endif


                      240
   256   257   258   259   260   261   262   263   264   265   266