Hello,
I have some problems to get a serial connection between Unity and my Arduino. When I use Serial.read(); the connection from Unity to my Arduino works fine but I'm only able to send one byte. In the code below happens the following. When I send a 0 to the Arduino (via the Serial Monitor) I get a 48. When I send a 10 I get a 49 and a 48.
When I use Serial.parseInt(); my Arduino works fine (it responds a 10 when I send a 10) but I get the IOException error on Unity.
Is there any way to read data like parseInt but use Serial.read(); so I can connect to Unity?
I count not find any solution in this forum but I'm not really familiar with Arduino, so maybe I already found something but wasn't able to understand it.
#include <Servo.h>
Servo myservo;
int input;
int state;
void setup()
{
myservo.attach(9);
Serial.begin(57600);
myservo.write(75);
delay(10);
}
void loop() {
if (Serial.available()>0) {
input = Serial.read();
myservo.write(input);
Serial.println(input);
delay (1);
}
}
Greetings
Exitras