How will i send this set of codes into arduino? then arduino will try to send this commands into my gsm shield, can anyone send me some sketch? im using arduino uno
this codes are from vb:
Try
With SerialPort1
.PortName = comports
.BaudRate = 9600
.Parity = Parity.None
.StopBits = StopBits.One
.DataBits = 8
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
.Open()
End With
Catch ex As Exception
End Try
Try
If SerialPort1.IsOpen Then
With SerialPort1
.Write("AT" & vbCrLf)
.Write("AT+CMGF=1" & vbCrLf)
.Write("AT+CMGS=" & Chr(34) & tbnumber.Text & Chr(34) & vbCrLf)
.Write(textmessage.Text & Chr(26))
MsgBox("Message Sent")
Please use code tags when posting code; edit your post and
type ** **[code]** **
before your code
type ** **[/code]** **
after your code
It is not advisable to throw exceptions away as you do in the first try/catch as you don't know what goes wrong.
I suggest that you read Serial Input Basics - updated to get ideas how to receive your data and place it in a buffer. Example 2 will probably do in which case you might want to change your VB code to only send a LF and not CR and LF. Example 3 will make the communication more reliable but requires more changes in your VB code.
Once you have received one command (e.g. AT), you can send that to the GSM using SoftwareSerial (if your shield uses serial communication). Next wait for the next command to arrive (AT+CMGF=1) and send that to the GSM in the same way.
I have no experience with GSM, you might have to wait for replies from the shield after you have send a command and possibly pass that reply to your VB code.