Page 125 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 125
Amphibionics 04 3/24/03 8:24 AM Page 104
Amphibionics
then compile the code. Program the PIC 16F84, as detailed in
Chapter 3, with the frog-test.hex file, listed in Program 4.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 apply power. If everything is
working properly, the LEDs should flash on and off while making
frog noises. When the light and sound stops, the servos should
start rotating in a forward direction toward the front of the robot.
If the servos are rotating in the opposite direction, then switch the
two servo connectors on the controller board.
'------------------------------------------------------------------------------------------------------------------------------
PROGRAM 4.1
' Name : Frog-test.bas
frog-test.bas program
' Compiler : PicBasic Pro MicroEngineering Labs
listing
' 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
switch_r VAR PORTA.4
104