' -----[ Title ]------------------------------------------------------------------- ' ' File.........U-Turn.txt (for robots with the Basic Stamp 2) ' Purpose......Forward and come back software for the Ebot ' Author.......Jim Ubersetzig ' Date.........6 Jun 2001 ' -----[ Revision History ]-------------------------------------------------------- ' ' 6 Jun 2001 original software ' -----[ General Description ]----------------------------------------------------- ' ' The Ebot rolls forward 10 feet, turns around and returns. ' Always use new batteries for contests ! ' -----[ Electrical Pin Connections ]---------------------------------------------- ' Right_Wheel con 5 ' this number is the I/O pin for the right motor Left_Wheel con 7 ' I/O pin for the left motor '-----[ Variables and Constants ]-------------------------------------------------- ' Offset con 750 'Neutral - motor stops Speed con 40 'Set for desired speed Ten_Feet con 111 'This number is adjusted until the robot rolls 10 feet. Turn_Around con 222 'Turns the robot around timer var word 'Keeps track of time. Adjust as necessary. '-----[ Main Code ]--------------------------------------------------------------- ' Start: Gosub Forward ' Roll forward 10 feet Gosub Turn ' Turn around Gosub Forward ' Roll back 10 feet Spin: Goto Spin ' Robot stops here Forward: For timer = 1 to Ten_Feet ' number of pulses to motors Pulseout Right_Wheel, Offset + Speed ' To roll forward the motors Pulseout Left_Wheel, Offset - Speed ' spin in opposite directions Pause 20 ' 20 millisecond wait Next ' Repeat pulses until done. Return ' End of this subroutine Turn: For timer = 1 to Turn_Around ' pulse count to turn around Pulseout Right_Wheel, Offset + Speed ' Offset alone stops the motor. Pulseout Left_Wheel, Offset + Speed ' Speed number sets how fast Pause 20 ' 20 millisecond wait Next ' Repeat pulses until done. Return ' End of "turn" subroutine ' End of Software