Hi there
I’m trying to read the serial data from my arduino. I am pretty sure the data is written correctly, because if I chach the serial output in Arduino it represents exactly the voltage from my sensor going up and down etc. So here is the code I’m using in Unity and it just gives a constant 130 (???) value.
SerialPort sp = new SerialPort("COM3", 9600);
void Start()
{
sp.Open();
sp.ReadTimeout = 5;
InvokeRepeating("readData", 0.5f, 0.5f);
}
void readData()
{
if (sp.IsOpen)
{
try
{
Debug.Log(sp.ReadByte());
}
catch(System.Exception)
{
}
}
}
Any advice appreciated!