Go Down

Topic: Arduino LM335 and visual basic 6 (Read 3 times) previous topic - next topic


ok, i understand,reason i ask about "getting rid of "@" is because i want to use that as a startbyte..

Story is....i am planning to build a computerized greenhouse and there will be about 10 to 15 diffrent sensors  attached to the arduino.

so from what i have understood i want something like.


where s1 s2 and s3 etc is the diffrent sensors

hope you understand


Yes you can send a long string over from the Arduino like  @a13.98b200c0.079d346e122.7 and use the VB string functions to select out each sensor value. You might write a function to simplify this

function GetSensorVal(BeginingLetTer,EndingLetter)  returns float or whatever

then to get the first value you could just call Val1 = GetSensorVal("c","d") and it would give you 0.079

You really don't need the @. I just used it as the start of the string since I am looking at only one temperature value and it made a good character to use when I was trying to identify the correct com port.


will try that.

now i have been able to get 2 sensors inplace however, if the second sensor shows a value less then 10 och more than 100 the strings get confused.
i beleive it is the threshold for mscomm1....cause if i incresase it by 1 and have a sensorvalue of ex 20 then the program program works fine but if it is less then 10 i have to decrease it by 1 and increase if sensorvalue is more than 100

how can i make the thresholds automaticlly sens how long the mystr is?



if the second sensor shows a value less then 10 or more than 100 the strings get confused.

on which end the VB or Arduino?  


i beleive it is the threshold for mscomm1

The com port only sees characters coming through.You need to use the string functions to find the start and end of the value you are looking for. Then if it is a 10 or a 1000 will make no difference.

so if your input string is a10b or a1000b it makes no difference to the code below

Code: [Select]

strt = InStr(str, "a") +1  ' one char past the a
 fin = InStr(str, "b")
 If (fin - strt) <= 0 Then
  Exit Function
  SensorVal =  Mid(str, strt, (fin - strt))


Go Up