ok, i copied your program and pasted it into mine, deleted my "oncomm..." etc and added at the end of your program label2.caption=Tempnow
i changed my < and > to your Tmp and @ in the arduino
but still nothing
here is the vb program
Private Sub Form_Load()
' Fire Rx Event Every Two Bytes
MSComm1.RThreshold = 5
' When Inputting Data, Input 2 Bytes at a time
MSComm1.InputLen = 5
' 2400 Baud, No Parity, 8 Data Bits, 1 Stop Bit
MSComm1.Settings = "9600,N,8,1"
' Make sure DTR line is low to prevent Stamp reset
MSComm1.DTREnable = False
' Open COM1
MSComm1.CommPort = 3
MSComm1.PortOpen = True
End Sub
Function TempNow() As Single
Dim str As String
Dim strt, fin, ct As Integer
Dim tempstr As String
Dim u As Single
Dim i, B As Integer
u = 0
str = ""
For i = 1 To 5
Sleep 10
str = MSComm1.Input
' I use "Tmp and "@" instead of "<" and ">"
If InStr(str, "Tmp") > 0 And InStr(str, "@") > 0 Then
GoTo J1
End If
Next i
J1:
ct = 0
u = 0
strt = InStr(str, "@-") + 2
fin = InStr(str, "-Tmp")
If (fin - strt) <= 0 Then
Exit Function
Else
ct = ct + 1
u = u + Mid(str, strt, (fin - strt))
End If
TempNow = u / ct
If Option1.Value = True Then
TempNow = TempNow * (9 / 5) + 32
Label2.Caption = TempNow
End If
End Function
and here is the arduino program
float temp_in_celsius = 0, temp_in_kelvin=0, temp_in_fahrenheit=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
//Reads the input and converts it to Kelvin degrees
temp_in_kelvin = analogRead(0) * 0.004882812 * 100;
//Converts Kelvin to Celsius minus 2.5 degrees error
temp_in_celsius = temp_in_kelvin - 2.5 - 273.15;
temp_in_fahrenheit = ((temp_in_kelvin - 2.5) * 9 / 5) - 459.67;
//Print the temperature in Celsius to the serial port
// Serial.print("Celsius: ");
Serial.print("Tmp");
Serial.print(temp_in_celsius);
Serial.print("@");
//Print the temperature in Fahrenheit to the serial port
//Serial.print("Fahrenheit: ");
//Serial.println(temp_in_fahrenheit);
// Serial.println();
delay(1000);
}
getting a headache...![]()