Interface - Unity & Arduino


For my interface week assignment, I used Unity to build an interactive interface between my Arduino board and a game scene. Unity is a powerful and widely-used game engine and development platform that allows for the creation of interactive 2D and 3D content. I used a serial controller asset to establish a connection between my Arduino board and Unity, enabling me to send and receive data between the two systems. In my project, I used data from a soil sensor to control the display of an image on the game scene plane within Unity. This demonstrated my ability to create dynamic and responsive interfaces using Unity and Arduino. I utilized my programming skills and knowledge of hardware to successfully integrate these two technologies, resulting in a unique and functional interface.





There are a few different ways to connect an Arduino board to Unity, but one common method is to use a serial controller asset. Here are the general steps to follow: First, make sure you have the Arduino software installed on your computer. Connect your Arduino board to your computer using a USB cable. Open the Arduino software and upload a sketch that sends data over the serial port. This sketch will run on the Arduino board and allow it to communicate with your computer. In Unity, create a new project and import the serial controller asset. This asset provides a set of scripts and tools that allow you to send and receive data over the serial port. In the Unity editor, create an empty game object and attach a serial controller script to it. This script will be responsible for managing the communication between Unity and the Arduino board. In the serial controller script, specify the serial port that the Arduino board is connected to. You can find this information in the Arduino software under the "Tools" menu. In your Unity script, use the serial controller script to send data to the Arduino board or receive data from it. For example, you might send a value from a slider in Unity to control a LED on the Arduino board, or receive data from a sensor on the Arduino board to update a display in Unity. That's a general overview of how to connect an Arduino board to Unity using a serial controller asset. It's also possible to use other methods, such as networking or MIDI, to establish a connection between the two systems.



I printed the analog values to the serial plotter and observe the feedback by placing the sensor into my plant. The valueswhen the sensor was in wet soil is over 700. When the sensor was out of the soil, it read around 0.