question please help me to solve this problem
andrewbenimaru
Posts: 6
hi everyone i was new student here i have few question to ask:
the question is i writting a visual basic 2005·program have a control box need to communicate with parallax bs2.
1. i have finish two control box which have function move forward backward right left and stop.
2. the·second control box·receive is through the internet reading the same ip to makesure that are connect.
3. the second control box is connect directly with the boe-bot car.
i have no idea how to make them work if i press forward the car will receive this message.
is very urgen please help me thanks.
the question is i writting a visual basic 2005·program have a control box need to communicate with parallax bs2.
1. i have finish two control box which have function move forward backward right left and stop.
2. the·second control box·receive is through the internet reading the same ip to makesure that are connect.
3. the second control box is connect directly with the boe-bot car.
i have no idea how to make them work if i press forward the car will receive this message.
is very urgen please help me thanks.
Comments
Alternately, if you have a parallel port on your computer you could use four lines of that to four inputs on the BS.
You could use an Parallax wireless RF modules for no wires.
Ir would have limited use (line of sight up to ~30ft) but this is also possible. You'd probably need the parallel port to implement this easily.
I hope this helps!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"puff"...... Smile, there went another one.
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
Select Case e.KeyChar
Case "2", "4", "5", "6", "8"
sendCommandToTrolley(AscW(e.KeyChar))
End Select
End Sub
Sub myMsgbox(ByVal str As String)
If CheckBox1.Checked Then
MsgBox(str)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
findPort(ComboBox1)
lblBaudRate.Text = SerialPort1.BaudRate
lblPortname.Text = SerialPort1.PortName.ToString
ComboBox1.Text = SerialPort1.PortName
Me.KeyPreview = True
End Sub
Private Sub sendCommandToTrolley(ByVal s2 As Byte)
Dim s(0) As Byte
Dim ex As System.Exception
Try
s(0) = s2
myMsgbox("Data being send : Ascii : " & s(0) & " Char : " & Convert.ToChar(s(0)))
SerialPort1.WriteTimeout = 500 ' time out if the data is not send in 1/2 a second
retryPort:
SerialPort1.Open() ' open port for serial communication
If SerialPort1.IsOpen Then
SerialPort1.Write(s, 0, 1) ' send data contained in array s[noparse][[/noparse]0]
SerialPort1.Close() ' close port
Else
Dim result As MsgBoxResult
result = MsgBox("port not open or unable to open port", MsgBoxStyle.RetryCancel)
If result = MsgBoxResult.Retry Then
GoTo retryPort
Else
Exit Sub
End If
End If
Catch ex
MsgBox(ex.Message & " " & Err.Number)
End Try
End Sub
Private Sub findPort(ByRef commPortCombo As ComboBox)
Dim s As String
For Each s In SerialPort.GetPortNames()
commPortCombo.Items.Add(s)
Next s
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
SerialPort1.PortName = ComboBox1.SelectedItem
lblPortname.Text = SerialPort1.PortName.ToString
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub SplitContainer1_Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
settings.ShowDialog()
End Sub
Private Sub btnForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForward.Click
sendCommandToTrolley(Asc("8"))
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
sendCommandToTrolley(Asc("5"))
End Sub
Private Sub btnLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLeft.Click
sendCommandToTrolley(Asc("4"))
End Sub
Private Sub btnRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRight.Click
sendCommandToTrolley(Asc("6"))
End Sub
Private Sub btnBackward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBackward.Click
sendCommandToTrolley(Asc("2"))
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
End Sub
End Class
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"puff"...... Smile, there went another one.
http://www.google.com/search?sourceid=navclient&ie=UTF-8&rlz=1T4GGIH_enUS316US316&q=Visual+BASIC+code+and+the+BASIC+Stamp
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Parallax Tech Support·
Typically, the way you use the serial port, you OPEN it in the 'load', LEAVE IT OPEN, then send bytes and recieve bytes.
You CLOSE the port when you exit the program.
Here is the link http://forums.parallax.com/showthread.php?p=671804
In particular look at "Com Template.zip"
Jeff T.
can you measure how to use it?
thanks~
am i need to start the basic stamp program ?
or i have to do something else?
i new student please teach me thank you.
please give me some clue~thanks!
' {$STAMP BS2}
' {$PBASIC 2.5}
main:
SEROUT 16,16468,[noparse][[/noparse]"#"]
SERIN 16,16468,25,timeout ,[noparse][[/noparse]DEC1 x]
timeout:
ON x GOSUB Halt,Forward,Back,Right,Left
GOTO main
END
Halt:
DEBUG "1"
RETURN
Forward:
DEBUG "2"
RETURN
Back:
DEBUG "3"
RETURN
Right:
DEBUG "4"
RETURN
Left:
DEBUG "5"
RETURN