'------------------------------------------------------ ' Name : turtle-receive.bas ' Compiler : PicBasic Pro - MicroEngineering Labs ' Notes : Robot remote control using the Linx 433LC ' : series transmitter and receiver. '------------------------------------------------------ ' PortA set as outputs. Pins 0 & 1 inputs. trisa = %00000011 ' 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 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 forward endif if control = "B" then gosub backwards 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 '------------------------------------------------------ ' movement subroutines forward: high enable_left high forward_left high enable_right high forward_right return '------------------------------------------------------ turn_left: high enable_left high forward_left high enable_right high reverse_right return '------------------------------------------------------ backwards: high enable_left high reverse_left high enable_right high reverse_right return '------------------------------------------------------ turn_right: high enable_left high reverse_left high enable_right high forward_right return end