Alanukdude
Technical User
Hi,
I've got this code below going to a servo attached to the com port...
'slowmove been dim'd as integer
slowmove = txtGripper1.Text
If txtGripper2.Text > txtGripper1.Text Then
Do Until slowmove = txtGripper2.Text
MSComm1.Output = Chr$(255)
MSComm1.Output = Chr$(4)
MSComm1.Output = Chr$(slowmove)
slowmove = slowmove + 1
Sleep 25
Loop
ElseIf txtGripper2.Text < txtGripper1.Text Then
Do Until slowmove = txtGripper2.Text
MSComm1.Output = Chr$(255)
MSComm1.Output = Chr$(4)
MSComm1.Output = Chr$(slowmove)
slowmove = slowmove - 1
Sleep 25
Loop
End If
when txtgripper2.text is greater than txtgripper1.text, this loop successfully sends a loop of the 3 lines above to the servo. incrementing 1 step at a time untill it equals txtgripper2. problem is when txtgripper2.text is less than txtgripper1.text. This should send the 3 lines to the com port with the 3rd one incremeting negatively to the same value as txtgripper2.text. But it don't it goes up and up until the servo reaches 254 where the program crashes.
txtgripper1 is 127 and this value is sent to the servo before this loop.
any thoughts on this as it is really getting to me.
I've got this code below going to a servo attached to the com port...
'slowmove been dim'd as integer
slowmove = txtGripper1.Text
If txtGripper2.Text > txtGripper1.Text Then
Do Until slowmove = txtGripper2.Text
MSComm1.Output = Chr$(255)
MSComm1.Output = Chr$(4)
MSComm1.Output = Chr$(slowmove)
slowmove = slowmove + 1
Sleep 25
Loop
ElseIf txtGripper2.Text < txtGripper1.Text Then
Do Until slowmove = txtGripper2.Text
MSComm1.Output = Chr$(255)
MSComm1.Output = Chr$(4)
MSComm1.Output = Chr$(slowmove)
slowmove = slowmove - 1
Sleep 25
Loop
End If
when txtgripper2.text is greater than txtgripper1.text, this loop successfully sends a loop of the 3 lines above to the servo. incrementing 1 step at a time untill it equals txtgripper2. problem is when txtgripper2.text is less than txtgripper1.text. This should send the 3 lines to the com port with the 3rd one incremeting negatively to the same value as txtgripper2.text. But it don't it goes up and up until the servo reaches 254 where the program crashes.
txtgripper1 is 127 and this value is sent to the servo before this loop.
any thoughts on this as it is really getting to me.