Page 358 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 358
Amphibionics 07 3/24/03 9:13 AM Page 337
Chapter 7 / Turtletron: Build Your Own Robotic Turtle
trisb = %00000001
sonar-map.bas program
listing (continued)
'------------------------------------------------------------------------------------------------------------------------------ PROGRAM 7.13
' initialize variables
trigger VAR PORTA.0
echo VAR PORTA.1
piezo VAR PORTA.3
switch VAR PORTB.0
enable_right VAR PORTB.1
forward_right VAR PORTB.2
reverse_right VAR PORTB.3
enable_left VAR PORTB.4
reverse_left VAR PORTB.5
forward_left VAR PORTB.6
dist_raw VAR WORD
dist_inch VAR WORD
conv_inch CON 15
I VAR BYTE
temp VAR BYTE
state VAR BYTE
best_pos VAR BYTE
most_space VAR BYTE
position VAR WORD[12]
low enable_left
low forward_left
low reverse_left
low enable_right
low forward_right
low reverse_right
SOUND PIEZO,[115,10,50,10]
start:
' rotate robot to the left
337