Hi

I have a one small problem, I cant figure it out ?

I have two buttons, PIC 16f877a and a Servo Motor.

My goal is when one button is pressed that motor turn left, and when another one button is pressed that motor turns to the right side, and motor should turn with low spead.
This is the code

button1 Var BIT
button2 Var BIT
i Var Byte

start:

If bottun1=1 then
for i= 1 to 50
PULSOUT portd.2, 220
PAUSE 20
next i
ELSE
ENDIF

IF button2=1 then
for i =1 to 50
PULSOUT portd.2, 80
PAUSE 20
next i
ELSE
ENDIF

GOTO start

Well this is quite easy and I've manage to do that, motor turn slowly to the left and right.
My porblem is that I wanna make program to run like this:

1. WHen button 1 is pressed motor turn slowly to one side, and If I relase button then motor stops at his current location (on my program above motor will stop only when it do FOR loop to the end)

2.If motor turn to one side, and I press second button how to make motor to turn on the other side, at same speed.


Ufff :)

THx