dwilches / Ardity

Assets for integrating Arduino and Unity (or Unity and any hardware that communicates over a COM port)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't compare strings (sorry am noob)

stefduijkers opened this issue · comments

Hi there,

I want to send a particular message if the message the arduino sends to unity is "Broken".
I'm just running some simple tests and have this code on the arduino:
switch (Serial.read())
{
case 'A':
Serial.println("Broken");
break;
}

So when i press A in Unity the message "Broken" will be sent back.

I want a response to that message to i put this code in Unity.

void OnMessageArrived(string msg)
{
Debug.Log(msg);
if(msg == "Broken") {
Debug.Log("It's broken y'all");
}

}

The "Broken" message gets logged but the message that should follow it ("It's broken y'all"), doesn't.
I know this is probably simple but i'm really new at programming.

Thanks for the help
Schermafbeelding 2022-04-26 om 14 09 56
!