Skip to content

Instantly share code, notes, and snippets.

@comoc
Last active August 19, 2019 10:13
Show Gist options
  • Select an option

  • Save comoc/edcff880d723822e0c8c57cc5aa5e2f5 to your computer and use it in GitHub Desktop.

Select an option

Save comoc/edcff880d723822e0c8c57cc5aa5e2f5 to your computer and use it in GitHub Desktop.
UnityからArduinoのデータをシリアル経由で取得したい!確かにArduinoからは出力しているはずなのに何もやって来ない。そんな時の対策 ref: https://qiita.com/comocc/items/43794313413091f23368
Serial.print("Hello");
Serial.println("");
serialPort_ = new SerialPort(portName, baudRate, Parity.None, 8, StopBits.One);
serialPort_.ReadTimeout = 1000; // 1000は適当な値です
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("Hello");
// Serial.println("");
Serial.println(); // Unity 2019.2.0f1 で確認したら、引数無しでないと動かなかった
delay(1000);
}
Serial.print("Hello");
Serial.println("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment