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:
B4X:
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.
Updates
- v1.20 - Uses a small console app to get the ports description.
Attachments
Last edited: