Hi
sorry for my bad english
I have a problem with comunication between smartphone e microcontroller via bluetooth.
I try to explain
Some years ago I did a program in VB6 that comunicate with a microcotroller for drive 5 servo RC through RS232
Belove a part of program that send then comand to the microcontroller
The command is divided into three parts like you see below
1) value of sinconization. evere 255
2) value of number of servo to drive ( 0 to 4)
3) value of position of servo ( 0 to 254) this valus is obtained by a slide
Part of program VB6
For ritardo = 1 To (Slider2.Value * 1)
MSComm1.Output = Chr(255) ' costant for sincronization of comunication
MSComm1.Output = Chr(u) ' number of servo
MSComm1.Output = Chr(Label20(u).Caption) ' slide’s value of servo postion ( 0 to 254 )
Next
Now I bought a little transciver bluetooth-RS232
I used the code by Erel for comunication between smartphone via bluetooh and use AsyncStreams to send messages.
If I try to comuincate with PC it work fine but when I connect with the microcontroller the servo don’t work.
The progam use e seekbar and take the value to send to the microcontroller.
Belove the part of program in B4A that send the comand to the microcontroler
Sub Vbar_ValueChanged(Value As Int, UserChanged As Boolean)
Dim valore() As Byte
Dim BC As ByteConverter
Dim a() As Byte
Dim b() As Byte
Dim c As Int
If UserChanged Then
label1.Text=Chr(Value)
c=255
a=BC.ShortsToBytes(Array As Short (c))
c=1
b=BC.ShortsToBytes(Array As Short (c))
valore=BC.ShortsToBytes(Array As Short ( Value))
AStream.Write(a)
AStream.Write(b)
AStream.Write(valore)
End If
End Sub
Where am I wrong?:BangHead:
Thank you in advance
sorry for my bad english
I have a problem with comunication between smartphone e microcontroller via bluetooth.
I try to explain
Some years ago I did a program in VB6 that comunicate with a microcotroller for drive 5 servo RC through RS232
Belove a part of program that send then comand to the microcontroller
The command is divided into three parts like you see below
1) value of sinconization. evere 255
2) value of number of servo to drive ( 0 to 4)
3) value of position of servo ( 0 to 254) this valus is obtained by a slide
Part of program VB6
For ritardo = 1 To (Slider2.Value * 1)
MSComm1.Output = Chr(255) ' costant for sincronization of comunication
MSComm1.Output = Chr(u) ' number of servo
MSComm1.Output = Chr(Label20(u).Caption) ' slide’s value of servo postion ( 0 to 254 )
Next
Now I bought a little transciver bluetooth-RS232
I used the code by Erel for comunication between smartphone via bluetooh and use AsyncStreams to send messages.
If I try to comuincate with PC it work fine but when I connect with the microcontroller the servo don’t work.
The progam use e seekbar and take the value to send to the microcontroller.
Belove the part of program in B4A that send the comand to the microcontroler
Sub Vbar_ValueChanged(Value As Int, UserChanged As Boolean)
Dim valore() As Byte
Dim BC As ByteConverter
Dim a() As Byte
Dim b() As Byte
Dim c As Int
If UserChanged Then
label1.Text=Chr(Value)
c=255
a=BC.ShortsToBytes(Array As Short (c))
c=1
b=BC.ShortsToBytes(Array As Short (c))
valore=BC.ShortsToBytes(Array As Short ( Value))
AStream.Write(a)
AStream.Write(b)
AStream.Write(valore)
End If
End Sub
Where am I wrong?:BangHead:
Thank you in advance