Hi,
have setup a testenvironment with an Arduino XBee Shield and a PC with XBee USB explorer.
1) Connected the Arduino via USB to the PC (COM4), put the XBee Shield in USB Mode (jumper settings), uploaded the B4R program, put the XBee Shield in XBee Mode (jumper settings),
2) Connected the XBee USB explorer with the PC (COM5), compiled the B4J Program and run.
Nothing happens. In the XCTU program COM4 and COM5 are recognized.
Any hints what could be wrong in the setup or code?
B4R Code
B4J Code
have setup a testenvironment with an Arduino XBee Shield and a PC with XBee USB explorer.
1) Connected the Arduino via USB to the PC (COM4), put the XBee Shield in USB Mode (jumper settings), uploaded the B4R program, put the XBee Shield in XBee Mode (jumper settings),
2) Connected the XBee USB explorer with the PC (COM5), compiled the B4J Program and run.
Nothing happens. In the XCTU program COM4 and COM5 are recognized.
Any hints what could be wrong in the setup or code?
B4R Code
B4X:
Sub Process_Globals
Public Serial1 As Serial
Private AStream As AsyncStreams
Private LED13 As Pin
End Sub
Private Sub AppStart
Serial1.Initialize(9600)
LED13.Initialize(13, LED13.MODE_OUTPUT)
AStream.Initialize(Serial1.Stream, "AStream_NewData", "AStream_Error")
End Sub
Sub AStream_NewData (Buffer() As Byte)
Dim ledStatus As Boolean
If Buffer(0) = 1 Then ledStatus = True Else ledStatus = False
Log("LED13 Status:", ledStatus)
LED13.DigitalWrite(ledStatus)
End Sub
Sub AStream_Error
Log("AStream Error")
End Sub
B4J Code
B4X:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private serial As Serial
Private astream As AsyncStreams
Private ToggleButton1 As ToggleButton
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UNIFIED")
MainForm.RootPane.LoadLayout("Main")
serial.Initialize("serial")
serial.Open("COM5")
astream.Initialize(serial.GetInputStream, serial.GetOutputStream, "Astream")
MainForm.Show
End Sub
Sub ToggleButton1_SelectedChange(Selected As Boolean)
Dim ledStatus As Byte
If Selected Then ledStatus = 1 Else ledStatus = 0
Log($"Send for LED 13 the Status ${ledStatus} to the Arduino."$)
astream.Write(Array As Byte(ledStatus))
End Sub