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

Amphibionics 04  3/24/03  8:24 AM  Page 111
                                         Chapter 4 / Frogbotic: Build Your Own Robotic Frog
                        lets go, the robot does not always leap forward. This introduces an
                        interesting random element, and this is the key to actually con-
                        trolling the robot’s in-flight direction. If you want to add sensors
                        and direction control to the robot, try writing a routine that will let
                        one of the legs release, and wait for a predetermined amount of
                        time before letting the other leg go. These values could be depend-
                        ent on the information that the microcontroller receives from the
                        sensor  input.  Compile  frogbotic.bas listed  in  Program  4.5,  and
                        then program the PIC 16F84 with the frogbotic.hex file listed in
                        Program 4.6. Insert the PIC 16F84 into the 18-pin socket on the
                        controller board. Place the robot on a flat surface and turn on the
                        power. Note that the robot should not be used on hardwood or
                        other types of flooring that scratches easily.


                        '------------------------------------------------------------------------------------------------------------------------------  PROGRAM 4.5
                        '  Name       : Frogbotic.bas
                                                                                   frogbotic.bas program
                        '  Compiler   : PicBasic Pro MicroEngineering Labs         listing
                        '  Notes       : Program to coordinate the jumping of
                        '                 : a robotic frog
                        '------------------------------------------------------------------------------------------------------------------------------

                        ' 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


                                                                                                 111
   127   128   129   130   131   132   133   134   135   136   137