Skip to content
This repository has been archived by the owner on Aug 21, 2021. It is now read-only.

problem reading Unity from Arduino with any other method than Serial.read() #11

Open
pr00thmatic opened this issue Aug 3, 2018 · 0 comments

Comments

@pr00thmatic
Copy link

Hi there! first of all... thanks for being so awesome!! your code works like a charm without fps drop :)

I am working on an Arduino Uno, under Windows 10 and Unity 2018.1.0f2 (64 bits).

There is a problem with the .send(message) method, it is easy to replicate:

open the scene WRMHLwrite and replace the loop method on the default arduino code on the ARDUINO.ino file with this code:

// Run forever
void loop() {
  sendData("Hello World!");

  if (Serial.available() > 0) {
    // int input = Serial.parseInt();
  }

  delay(20); // Choose your delay having in mind your ReadTimeout in Unity3D
}

This works OK, as the RX yellow light blinks when you play your unity game (unity is sending data from the update). But when you uncomment the line

int input = Serial.parseInt();

strange things begin to happen: when you play your game, both RX and TX lights blink once, and then the RX light turns off... the arduino stops receiving data!! also, weird things begin to happen with the data the arduino sends, and the serial port gets locked, not allowing you to upload new code to the arduino o.O (even when you stop your game on unity! o__O).

however, if you substitute that line for:

int input = Serial.read();

everything works just fine :)

I can't figure out where the error is on the code, but i'll keep searching, if I find something, i'll submit a pull request, but by now, I'll just leave this issue open over here...

sorry for my bad english :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant