#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
'Dim lcd16x2 As LiquidCrystal
Private result As Byte
Dim readA As Timer
End Sub
Private Sub AppStart
Serial1.Initialize(2400)
Log("AppStart")
readA.Initialize("readA_Tick",100)
readA.Enabled=True
End Sub
Sub readA_Tick
RunNative("serialread",Null)
Log("Serial Value : " ,result)
End Sub
#If c++
void setupserial(B4R::Object* o) {
Serial.begin(2400, SERIAL_7N1);
}
void serialread(B4R::Object* o){
if (Serial.available()){
String value = Serial.readString();
b4r_main::_result = value;
}
}
#End If