'------------------------------------------------------ ' Name : walk-routines.bas ' Compiler : PicBasic Pro - MicroEngineering Labs ' Notes : various walking subroutines '------------------------------------------------------ ' PortA set as outputs. pins 0 and 1 inputs trisa = %00000011 ' PortB set as outputs. pin 1 input. trisb = %00000001 '------------------------------------------------------ ' initialize variables include "modedefs.bas" 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 limit_left VAR PORTA.0 limit_right VAR PORTA.1 piezo VAR PORTA.3 temp VAR BYTE 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: '------------------------------------------------------ ' walking subroutines walk_forward: For temp = 1 to 5 ' move left leg high enable_left high forward_left pause 300 while limit_left = 0 wend low enable_left low forward_left ' move right leg high enable_right high forward_right pause 300 while limit_right = 0 wend low enable_right low forward_right next temp '------------------------------------------------------ turn_left: For temp = 1 to 5 ' move left leg high enable_left high reverse_left pause 300 while limit_left = 0 wend low enable_left low reverse_left ' move right leg high enable_right high forward_right pause 300 while limit_right = 0 wend low enable_right low forward_right next temp '------------------------------------------------------ walk_reverse: For temp = 1 to 5 ' move left leg high enable_left high reverse_left pause 300 while limit_left = 0 wend low enable_left low reverse_left ' move right leg high enable_right high reverse_right pause 300 while limit_right = 0 wend low enable_right low reverse_right next temp '------------------------------------------------------ turn_right: For temp = 1 to 5 ' move left leg high enable_left high forward_left pause 300 while limit_left = 0 wend low enable_left low forward_left ' move right leg high enable_right high reverse_right pause 300 while limit_right = 0 wend low enable_right low reverse_right next temp goto start end