Hi
My friend made some kind of timer with PIC16F876A and asked me to make an app to control that timer.
Timer has 256 bytes where I have to write some values. He programmed a timer in a way that data is written/read into/from registers by sending letter W/R and corresponding bytes after that.
There are also 4 servos that are controlled by a slider which can have values from 0 to 1023 (Short - 2 bytes).
To control e.g. first servo I have to send letter A and a slider value (3 bytes in total: one for A and 2 for Short Slider value). Moving slider should move servo in real time.
I have to point out that I am quite new with using B4A and that I am not a "born" programmer so if I ask some "stupid" questions I apologize in advance.
To make that app I took UsbToSerial Example so I managed to make a connection to the timer and when I move slider, sometimes servo moves but not all the time as it should.
The code I use to move servo is this:
My question is, of course, What am I doing wrong?
Tnanks
My friend made some kind of timer with PIC16F876A and asked me to make an app to control that timer.
Timer has 256 bytes where I have to write some values. He programmed a timer in a way that data is written/read into/from registers by sending letter W/R and corresponding bytes after that.
There are also 4 servos that are controlled by a slider which can have values from 0 to 1023 (Short - 2 bytes).
To control e.g. first servo I have to send letter A and a slider value (3 bytes in total: one for A and 2 for Short Slider value). Moving slider should move servo in real time.
I have to point out that I am quite new with using B4A and that I am not a "born" programmer so if I ask some "stupid" questions I apologize in advance.
To make that app I took UsbToSerial Example so I managed to make a connection to the timer and when I move slider, sometimes servo moves but not all the time as it should.
The code I use to move servo is this:
B4X:
Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
Dim comm1 As String
comm1 = "A"&BC.ShortsToBytes(Array As Short(Value))
...
astreams1.Write(comm1.GetBytes("UTF8"))
End Sub
My question is, of course, What am I doing wrong?
Tnanks