This is a small B4J program that uses jSerial library to connect to an Arduino board.
To see it working start with this simple B4R program:
Sub Process_Globals Public Serial1 As Serial Private astream As AsyncStreams End Sub Private Sub AppStart Serial1.Initialize(115200) Log("AppStart") astream.Initialize(Serial1.Stream, "Astream_NewData", "Astream_Error") End Sub Sub Astream_NewData (Buffer() As Byte) Log("Received: ", Buffer) End Sub Sub AStream_Error Log("error") End Sub
In this mode the IDE will send a message to the serial connector to close the serial port during compilation and to open it afterward.
You can modify the code to send binary data instead of strings.
Serial connector requires jSerial v1.30+: https://www.b4x.com/android/forum/threads/jserial-library.34762/page-1
4.9 KB Views: 229