Page 129 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 129
Amphibionics 04 3/24/03 8:24 AM Page 108
Amphibionics
PROGRAM 4.3
' Name : Limit-switch.bas
limit-switch.bas program
' Compiler : PicBasic Pro MicroEngineering Labs
listing '------------------------------------------------------------------------------------------------------------------------------
' Notes : Program to monitor the status of the leg
' : position limit switches and turn on the
' : corresponding LED when triggered
'------------------------------------------------------------------------------------------------------------------------------
' 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
switch_l VAR PORTA.3
led_l VAR PORTB.1
led_r VAR PORTB.0
piezo VAR PORTB.4
low servo_l
low servo_r
'------------------------------------------------------------------------------------------------------------------------------
start:
108