Hi,
I am trying to create a program in Visual Basic wherein the data is coming from Arduino via Serial port. A program for a fuel consumption meter (gravimetric method) that I am doing.
The idea of the program is this, when I connect to the serial port of my Arduino the serial will be immediately open. Then when I click another button, it will start a timer which will run for 5 secs. The data read at the end of 5 secs will be saved as the initial weight of the fuel and be used later on. After 5 seconds the same button will be clicked and once again run another timer but this time for 10 secs. Again, the data read at the end of time will be saved as the final weight.
The initial weight, final weight, and time (10 secs) will be used to compute the fuel consumption.
I am only able to do this, receive data from serial port and run timer. However, I don't know how to retrieve the data at the end of the time. How do I do that?
The code for my serial port dataReceived is this:
As of now the code for my button contains the code to run the timer.
Thank you.
I am trying to create a program in Visual Basic wherein the data is coming from Arduino via Serial port. A program for a fuel consumption meter (gravimetric method) that I am doing.
The idea of the program is this, when I connect to the serial port of my Arduino the serial will be immediately open. Then when I click another button, it will start a timer which will run for 5 secs. The data read at the end of 5 secs will be saved as the initial weight of the fuel and be used later on. After 5 seconds the same button will be clicked and once again run another timer but this time for 10 secs. Again, the data read at the end of time will be saved as the final weight.
The initial weight, final weight, and time (10 secs) will be used to compute the fuel consumption.
I am only able to do this, receive data from serial port and run timer. However, I don't know how to retrieve the data at the end of the time. How do I do that?
The code for my serial port dataReceived is this:
Code:
Private Sub spObj_DataReceived(sender As System.Object, e As System.IO.Ports.SerialDataReceivedEventArgs) Handles spObj.DataReceived
Dim txt As String
txt = ShowData(spObj.ReadLine)
tbox_iw.Text = txt 'the data will appear in a textbox dedicated for the initial weight'
End Sub
Function ShowData(ByVal [text] As String)
If Me.tbox_iw.InvokeRequired Then
Dim x As New SetTextCallBack(AddressOf ShowData)
Me.Invoke(x, New Object() {(text)})
End If
Return [text]
End Function
Thank you.