VB6 BS2px Servo
KennyR
Posts: 15
Im using a GUI made in Visual Basic 6 to send a character to my BS2px to control a servo. I have the GUI set up so when i press and hold a button down the servo should move and when i release that same button the servo should stop. But when i press and hold the button down on the GUI the servo pulses once and stops. Im not sure if its my BS2 code or my Visual Basic 6 code because I've used this VB6·coding before·to zoom a camera in and out and it performed great.
Visual Basic Code:
Private Sub Command19_mousedown(button As Integer, shift As Integer, x As Single, y As Single)
MSComm1.Output = Chr(20)
End Sub
Private Sub Command19_Click()
MSComm1.Output = Chr(19)
End Sub
BS2px Code:
gui VAR Word
Init:
gui = 0
Main:
DO
SERIN 16, 16780, [noparse][[/noparse]gui]
IF gui = 20 THEN
PULSOUT 13, 650
PAUSE 20
ENDIF
IF gui = 19 THEN
PULSOUT 13, 750
PAUSE 20
ENDIF
LOOP
Visual Basic Code:
Private Sub Command19_mousedown(button As Integer, shift As Integer, x As Single, y As Single)
MSComm1.Output = Chr(20)
End Sub
Private Sub Command19_Click()
MSComm1.Output = Chr(19)
End Sub
BS2px Code:
gui VAR Word
Init:
gui = 0
Main:
DO
SERIN 16, 16780, [noparse][[/noparse]gui]
IF gui = 20 THEN
PULSOUT 13, 650
PAUSE 20
ENDIF
IF gui = 19 THEN
PULSOUT 13, 750
PAUSE 20
ENDIF
LOOP
Comments
Because if you don't, the Serial port will reset the BS2 every time you open it.
And I think you want the BS2 variable "gui" to be a BYTE -- SERIN recieves bytes unless some pseudo-directive (like STR) tells it otherwise.