Communication between Arduino and Unity


This might be the simplest way to communicate between Arduino and Unity. I use the serial port to communicate between Arduino and Unity.

In Unity, set the network configuration as NET 2.0 instead of NET 2.0 subset.


Arduino Part

  1. Set a baud rate in the Arduino code by Serial.begin(9600);
  2. Serial.flush(); Waits for the transmission of outgoing serial data to complete.
  3. Serial.println(); Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or ‘\r’) and a newline character (ASCII 10, or ‘\n’). This command takes the same forms as Serial.print().
  4. The Port name can be found on the bottom right corner of the Arduino interface or on the Tools> Port > …. Mine is “/dev/cu.usmodem1421”
Arduino Code


  1. Use the System.IO.Ports library
  2. Set the port and baud rate by SerialPort stream = new SerialPort (“device name here”, 9600);
  3. Initialize: stream.Open();
  4. In update, read the stream data by stream.ReadLine();
  5. Display the information received on GUI
Unity Code (c#)



Product Designer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store