' ========================================================================= ' ' File....... Servo_Pan.BS1 ' Purpose.... Simple servo control with PULSOUT ' Author..... CindyBob.com adapted from Simple Servo Control by Parallax EFX ' Updated.... 03 Apr 2006 ' ' {$STAMP BS1} ' {$PBASIC 1.0} ' ' ========================================================================= SYMBOL Servo = 0 ' Pin number SYMBOL HeadMaxLeft = 90 ' Servo position for Head turned left SYMBOL HeadCenter = 150 ' Servo position for Head centered SYMBOL HeadMaxRight = 200 ' Servo position for Head turned right SYMBOL i = B3 Setup: DIRS = %00000001 ' servo is output GOSUB Center PAUSE 250 Main: GOSUB TurnRight PAUSE 250 GOSUB TurnLeft PAUSE 250 GOTO MAIN Center: FOR I=0 TO 200 PULSOUT Servo,HeadCenter ' Send servo pulse PAUSE 20 ' Wait 1/50th second. NEXT I RETURN TurnRight: FOR I=0 TO 200 PULSOUT Servo,HeadMaxRight ' Send servo pulse. PAUSE 20 ' Wait 1/50th second. NEXT I RETURN TurnLeft: FOR I=0 TO 200 PULSOUT Servo,HeadMaxLeft ' Send servo pulse. PAUSE 20 ' Wait 1/50th second. NEXT I RETURN