Hi Guys,
I’m trying to send many ints to my “masterArduino”.
Because the SerialPort object only send strings. I’ve tried many things including:
- Creating a string from ints ( didn’t work because the size of the string.length is dynamic).
- Then i tried to convert these ints to chars, this because all values are between 0-255, then put the char into a string and send it.
This sort of works. However i think there is no value for 0 in char world. So the data is not right. But there must be a better way?
void sendInfo()
{
for (var i = 0; i < peltiers.Length; i++)
{
char tempHot = (char) peltiers*.GetComponent<Peltier>().hot;*
char charTemp = (char) peltiers*.GetComponent().temp;*
peltierInfo += tempHot.ToString();
peltierInfo += charTemp.ToString();
}
sp.WriteLine(peltierInfo);
Debug.Log(peltierInfo);
sp.BaseStream.Flush();
peltierInfo = “”;
}
Any help would be greatly appreciated! Thanks!