Cool servo program w/ potentioment

Hello, after speading about 5 hours scruwing around with my atom, I came up with a program that can take a value from a pot and rotate a servo in the direct as long as the pot is that specific value. Also, the servo stays at that position when the pot is back to 0 degrees. (check out code :wink: )
what my question is is that my program has the servo stop at my desired position but doesn’t hold. If anyone has any idea how to get the servo value before it stops and have it hold that position instead of doing nothing.

[code]’=========variables=============
yservo var sword
counter var sword
counter = 0
ttime var bit
ttime = 1

'=========maincode=============

loopit:
adin ax0,1,ad_ron,yservo

if yservo < 700 then
repeat
counter = (counter - 25)
servo p5, counter, ttime
adin ax0,1,ad_ron,yservo
until yservo > 700

elseif yservo > 710
repeat
adin ax0,1,ad_ron,yservo
counter = (counter + 25)
servo p5, counter, ttime
until yservo < 710
else
gosub nothing
endif

goto loopit

'===========subcommand==============

nothing:
pause 1
return

[/code]

Bane

ha :unamused: , figured it out!

(hope this code will be useful for joy stick controlled robots)

[code]’=========variables=============
yservo var sword
counter var sword
counter = 0
ttime var bit
ttime = 1

'=========maincode=============

loopit:
adin ax0,1,ad_ron,yservo

if yservo < 700 then
repeat
counter = (counter - 25)
servo p5, counter, ttime
adin ax0,1,ad_ron,yservo
until yservo > 700

elseif yservo > 710
repeat
adin ax0,1,ad_ron,yservo
counter = (counter + 25)
servo p5, counter, ttime
until yservo < 710
else
gosub hold
endif

goto loopit

'===========subcommand==============

hold:
servo p5, counter, ttime
return[/code]

man i’m really getting hang of programming :smiley: .
this program has advance speed control.
(if the joy moves a little then the servo moves little and vise versa)

[code]’=========variables=============
yservo var sword
counter var sword
math var sbyte
ttime var bit
counter = 0
ttime = 1
math = 1

'=========maincode=============

loopit:
adin ax0,1,ad_ron,yservo
if yservo < 650 then
math = 1
repeat
counter = (counter + math)
if yservo > 640 then
math = 3
endif

	servo p5, counter, ttime
	adin ax0,1,ad_ron,yservo
	math = (math + 1)
		until yservo > 650

elseif yservo > 700
math = 1
repeat
counter = (counter - math)
if yservo < 710 then
math = 3
endif
servo p5, counter, ttime
adin ax0,1,ad_ron,yservo
math = (math + 1)
until yservo < 700

else
gosub hold
endif

goto loopit

'===========subcommand==============

hold:
servo p5, counter, ttime
return[/code]