'------------------------------------------------------ ' Name : rx-remote.bas ' Compiler : PicBasic Pro - MicroEngineering Labs ' Notes : Robot remote control using the Linx 433LC ' : series transmitter and receiver. '------------------------------------------------------ ' PortA set as outputs trisa = %00000000 ' PortB set as outputs. pin 0 input. trisb = %00000001 '------------------------------------------------------ ' initialize variables include "modedefs.bas" rx_baud CON N2400 rxmit 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 limit_left VAR PORTA.0 limit_right VAR PORTA.1 piezo VAR PORTA.3 control VAR BYTE 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: serin rxmit,rx_baud,["Z"],control if control = "A" then gosub walk_forward endif if control = "B" then gosub walk_reverse endif if control = "C" then gosub turn_left endif if control = "D" then gosub turn_right endif if control = "E" then sound piezo,[115,10,50,10] endif if control = "F" then low enable_left low forward_left low reverse_left low enable_right low forward_right low reverse_right endif goto start '------------------------------------------------------ ' walking subroutines walk_forward: ' 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 return '------------------------------------------------------ turn_left: ' 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 return '------------------------------------------------------ walk_reverse: ' 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 return '------------------------------------------------------ turn_right: ' 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 return end