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

Amphibionics 05  3/24/03  8:44 AM  Page 165
                                       Chapter 5 / Serpentronic: Build Your Own Robotic Snake
                        Program  the  PIC  16F84  with  the  snake-test.hex file  listed  in
                        Program 5.2. When the chip has been successfully programmed,
                        insert it into the 18-pin I.C. socket on the main controller board
                        with the notch and pin 1 facing toward the LEDs and then turn the
                        power switch to the “ON” position. If everything is working prop-
                        erly, the LEDs should flash on and off while making random nois-
                        es. When the light and sound stops, the servos should all move to
                        the middle position, making the snake straight. If the snake is not
                        relatively straight, keep the power turned on and readjust each of
                        the  servo  horns  so  that  it  is  straight.  If  nothing  happens  when
                        power is applied, then check all of the battery and circuit board
                        connections. Also, make sure that the PIC 16F84 was programmed
                        properly.


                        '------------------------------------------------------------------------------------------------------------------------------
                                                                                   PROGRAM 5.1
                        '  Name       : Snake-test.bas
                                                                                   snake-test.bas program
                        '  Compiler   : PicBasic Pro - MicroEngineering Labs
                                                                                   listing
                        '  Notes       : Program to test the main controller
                        '                 : board by flashing the LEDs, producing
                        '                 : sounds and setting each of the servos to
                        '                 : their middle positions
                        '------------------------------------------------------------------------------------------------------------------------------

                        ' PortA set as outputs
                        trisa = %00000000

                        ' PortB set as outputs. pins 0-1 inputs
                        trisb = %00000011

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


                        led_left         VAR PORTA.2
                        led_right       VAR PORTA.3
                        piezo            VAR PORTA.4
                        servo_1        VAR PORTB.2


                                                                                                 165
   181   182   183   184   185   186   187   188   189   190   191