Ok, download VB express 2010, if you haven't already.
Start a new project.
Stick a timer control onto the form.
Then double click the form to get into the code.
After one of the "End Sub" 's, copy and paste the following function, not forgetting to set the correct COM port you are using:
Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String = ""
Using com As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSerialPort("com4")
Dim Incoming As String = com.ReadLine()
If Incoming Is Nothing Then
MsgBox("No Data Captured.")
Else
returnStr &= Incoming & vbCrLf
End If
End Using
Return returnStr
MsgBox("Fail!")
End Function
Then scroll all the way to the top of the code for the program, and paste the following:
Imports System.IO
That's the code to get the serial data.
Now go back to your form, and click the timer you placed earlier. Change the interval to 1000.
Double click the timer to get into the code for it.
Here is where you will enter the code to be executed each time 1 second passes.
So you'd want something like:
If receiveSerialData() = "1" Then
'code here
End If
As I mentioned previously, the built-in Now() function is useful for getting the current date and time.