Shop OBEX P1 Docs P2 Docs Learn Events
Controlling servo via visual basic VScrollbar — Parallax Forums

Controlling servo via visual basic VScrollbar

karabetkarabet Posts: 17
edited 2010-02-14 13:43 in BASIC Stamp
Hi,
I’m building a BS2 servo controller via serial port the bS2 script is
' {$STAMP BS2}
' {$PBASIC 2.5}
·counter VAR Byte
·servo VAR Byte
PinNumber VAR Byte
·
SERIN 16,16780,[noparse][[/noparse]WAIT(255),PinNumber, servo]
·
FOR counter = 1 TO 150
· PULSOUT PinNumber,servo
· PAUSE 20
NEXT
END
·
I would like to control the servo via Visual basic 6 program but didn’t succeed, can someone help me please. I’m using the VScroollbar· and the VB code is:

Option Explicit
Private Sub Form_Load()
Dim Pins As Long
'· Add the pin numbers 0 to 15 to cboPinNumber
For Pins = 0 To 15
··· cboPinNumber.AddItem CStr(Pins)
Next Pins
' Default to Pin 0 being selected
cboPinNumber.ListIndex = 0
' Default to optState(0) being selected

'· Use COM1
MSComm1.CommPort = 1
' 2400 baud, no parity, 8 data bits, 1 stop bit
MSComm1.Settings = "2400,N,8,1"
' Make sure DTR line is low to prevent Stamp reset
MSComm1.DTREnable = True

' Open the port
MSComm1.PortOpen = True
End Sub
Private Sub VScroll1_Change()
Dim servo As Long
Dim cboPinNumber As Long
Text1.Text = VScroll1.Value
servo = Text1.Text
MSComm1.Output = Chr$(255) & Chr$(cboPinNumber)
MSComm1.Output = Chr$(Text1.Text)
End Sub
Private Sub VScroll1_Scroll()
VScroll1_Change
End Sub
·
Can someone help please is there an example for this subject.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards,

Karabet


Post Edited (karabet) : 2/13/2010 10:14:36 AM GMT
328 x 246 - 8K

Comments

Sign In or Register to comment.