# Controlling Objects in Unity with a 9 DoF Sensor and Arduino ## Overview ![](https://cdn-learn.adafruit.com/assets/assets/000/114/587/medium800thumb/projects_tiltGif.jpg?1661887566) [Unity](https://en.wikipedia.org/wiki/Unity_(game_engine)) is one of the most widely used game engines for developing video games. In this guide, you'll learn how to integrate your Arduino based hardware projects with your Unity projects to create interactive experiences. Data from a 9 DoF sensor is sent over a serial connection from the board to a C# script in Unity. The C# script is set up to affect Unity objects with the incoming data. ![](https://cdn-learn.adafruit.com/assets/assets/000/114/586/medium800/projects_edited_P1380743.jpg?1661886666) ## Calibrating Your 9 DoF Sensor The Adafruit LSM6DS3TR-C + LIS3MDL board has an accelerometer, gyroscope and magnetometer onboard, making it a 9 Degrees of Freedom (DoF) sensor. You can calibrate the various sensors for the most accurate movement measurements possible using the [How to Fuse Motion Sensor Data into AHRS Orientation Learn Guide](https://learn.adafruit.com/how-to-fuse-motion-sensor-data-into-ahrs-orientation-euler-quaternions/overview).  By following that guide, your chosen Arduino board stores the calibration in non-volatile memory so that it can be accessed going forward. Unity expects Quaternion values for rotation, so that calibration method is the most useful. [How to Fuse Motion Sensor Data into AHRS Orientation (Euler/Quaternions)](https://learn.adafruit.com/how-to-fuse-motion-sensor-data-into-ahrs-orientation-euler-quaternions/overview) There is Arduino code included for using the LSM6DS3TR-C + LIS3MDL sensor without calibration. It takes the accelerometer readings and uses the Arduino `map_range()` function to map the values between `-180` and `180` for Euler readings. It won't be as accurate as a fully calibrated sensor, but it will demonstrate how to input data into Unity. ## Prerequisite Guides [Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU](https://learn.adafruit.com/adafruit-lsm6ds3tr-c-lis3mdl-precision-9-dof-imu/overview) ## Parts An M0 or M4 board works best for this project, especially if you're using a stored calibration for the sensor.  ### Adafruit Metro M4 feat. Microchip ATSAMD51 [Adafruit Metro M4 feat. Microchip ATSAMD51](https://www.adafruit.com/product/3382) Are you ready? Really ready? Cause here comes the fastest, most powerful Metro ever. The **Adafruit Metro M4** featuring the **Microchip ATSAMD51**. This Metro is like a bullet train, with its 120MHz Cortex M4 with floating point support. Your code will zig and zag... In Stock [Buy Now](https://www.adafruit.com/product/3382) [Related Guides to the Product](https://learn.adafruit.com/products/3382/guides) ![Angled shot of a Adafruit Metro M4 feat. Microchip ATSAMD51. ](https://cdn-shop.adafruit.com/640x480/3382-13.jpg) ### Adafruit Feather M4 Express - Featuring ATSAMD51 [Adafruit Feather M4 Express - Featuring ATSAMD51](https://www.adafruit.com/product/3857) It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox, half bird, OK?) This feather is powered by our new favorite chip, the **ATSAMD51J19** -  with... In Stock [Buy Now](https://www.adafruit.com/product/3857) [Related Guides to the Product](https://learn.adafruit.com/products/3857/guides) ![Angled shot of a Adafruit Feather M4 Express. ](https://cdn-shop.adafruit.com/640x480/3857-06.jpg) ### Adafruit QT Py - SAMD21 Dev Board with STEMMA QT [Adafruit QT Py - SAMD21 Dev Board with STEMMA QT](https://www.adafruit.com/product/4600) What a cutie pie! Or is it... a QT Py? This diminutive dev board comes with our favorite lil chip, the SAMD21 (as made famous in our GEMMA M0 and Trinket M0 boards). This time it comes with [our favorite connector - the STEMMA QT](http://adafruit.com/stemma), a chainable I2C... In Stock [Buy Now](https://www.adafruit.com/product/4600) [Related Guides to the Product](https://learn.adafruit.com/products/4600/guides) ![Animation of Adafruit QT Py with onboard NeoPixel in a rainbow swirl.](https://cdn-shop.adafruit.com/product-videos/640x480/4600-07.jpg) ### Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU [Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU](https://www.adafruit.com/product/5543) Add high-quality motion, direction, and orientation sensing to your Arduino project with this all-in-one 9 Degree of Freedom (9-DoF) sensor with sensors from ST. This little breakout contains two chips that sit side-by-side to provide 9 degrees of full-motion data. The board... Out of Stock [Buy Now](https://www.adafruit.com/product/5543) [Related Guides to the Product](https://learn.adafruit.com/products/5543/guides) ![Angled shot of 9-DOF breakout board.](https://cdn-shop.adafruit.com/640x480/5543-06.jpg) ### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long [STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210) This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove. Out of Stock [Buy Now](https://www.adafruit.com/product/4210) [Related Guides to the Product](https://learn.adafruit.com/products/4210/guides) ![Angled shot of STEMMA QT / Qwiic JST SH 4-pin Cable.](https://cdn-shop.adafruit.com/640x480/4210-00.jpg) ### Part: USB A to USB C Cable quantity: 1 Pink and Purple Woven USB A to USB C Cable - 1 meter long [USB A to USB C Cable](https://www.adafruit.com/product/5153) ### Part: USB A to micro B Cable quantity: 1 Fully Reversible Pink/Purple USB A to micro B Cable - 1m long [USB A to micro B Cable](https://www.adafruit.com/product/4111) - [Next Page](https://learn.adafruit.com/controlling-objects-in-unity-with-arduino/install-and-setup-unity-with-visual-studio.md) ## Featured Products ### Adafruit Metro M4 feat. Microchip ATSAMD51 [Adafruit Metro M4 feat. Microchip ATSAMD51](https://www.adafruit.com/product/3382) Are you ready? Really ready? Cause here comes the fastest, most powerful Metro ever. The **Adafruit Metro M4** featuring the **Microchip ATSAMD51**. This Metro is like a bullet train, with its 120MHz Cortex M4 with floating point support. Your code will zig and zag... In Stock [Buy Now](https://www.adafruit.com/product/3382) [Related Guides to the Product](https://learn.adafruit.com/products/3382/guides) ### Adafruit Feather M4 Express - Featuring ATSAMD51 [Adafruit Feather M4 Express - Featuring ATSAMD51](https://www.adafruit.com/product/3857) It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox, half bird, OK?) This feather is powered by our new favorite chip, the **ATSAMD51J19** -  with... In Stock [Buy Now](https://www.adafruit.com/product/3857) [Related Guides to the Product](https://learn.adafruit.com/products/3857/guides) ### Adafruit QT Py - SAMD21 Dev Board with STEMMA QT [Adafruit QT Py - SAMD21 Dev Board with STEMMA QT](https://www.adafruit.com/product/4600) What a cutie pie! Or is it... a QT Py? This diminutive dev board comes with our favorite lil chip, the SAMD21 (as made famous in our GEMMA M0 and Trinket M0 boards). This time it comes with [our favorite connector - the STEMMA QT](http://adafruit.com/stemma), a chainable I2C... In Stock [Buy Now](https://www.adafruit.com/product/4600) [Related Guides to the Product](https://learn.adafruit.com/products/4600/guides) ### Adafruit Metro Mini 328 V2 - Arduino-Compatible - 5V 16MHz [Adafruit Metro Mini 328 V2 - Arduino-Compatible - 5V 16MHz](https://www.adafruit.com/product/5597) [**Now available here!**](http://www.adafruit.com/product/2590) One of our [star development boards is the  **Adafruit METRO Mini 328**](https://www.adafruit.com/product/2590), an excellent lil fellow that lets you make your... No Longer Stocked [Buy Now](https://www.adafruit.com/product/5597) [Related Guides to the Product](https://learn.adafruit.com/products/5597/guides) ### Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU [Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU](https://www.adafruit.com/product/5543) Add high-quality motion, direction, and orientation sensing to your Arduino project with this all-in-one 9 Degree of Freedom (9-DoF) sensor with sensors from ST. This little breakout contains two chips that sit side-by-side to provide 9 degrees of full-motion data. The board... Out of Stock [Buy Now](https://www.adafruit.com/product/5543) [Related Guides to the Product](https://learn.adafruit.com/products/5543/guides) ### STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long [STEMMA QT / Qwiic JST SH 4-pin Cable - 100mm Long](https://www.adafruit.com/product/4210) This 4-wire cable is a little over 100mm / 4" long and fitted with JST-SH female 4-pin connectors on both ends. Compared with the chunkier JST-PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove. Out of Stock [Buy Now](https://www.adafruit.com/product/4210) [Related Guides to the Product](https://learn.adafruit.com/products/4210/guides) ### Pink and Purple Woven USB A to USB C Cable - 1 meter long [Pink and Purple Woven USB A to USB C Cable - 1 meter long](https://www.adafruit.com/product/5153) This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also made for USB C for our modernized breakout boards, Feathers, and more.  [If you want something just like it but for Micro B, we...](https://www.adafruit.com/product/4111) Out of Stock [Buy Now](https://www.adafruit.com/product/5153) [Related Guides to the Product](https://learn.adafruit.com/products/5153/guides) ### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long [Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111) This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around. First let's talk about the cover and over-molding. We got these... In Stock [Buy Now](https://www.adafruit.com/product/4111) [Related Guides to the Product](https://learn.adafruit.com/products/4111/guides) ## Related Guides - [Adafruit Metro M4 Express featuring ATSAMD51](https://learn.adafruit.com/adafruit-metro-m4-express-featuring-atsamd51.md) - [Adafruit Feather M4 Express](https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51.md) - [Adafruit QT Py SAMD21](https://learn.adafruit.com/adafruit-qt-py.md) - [Adafruit LSM6DS3TR-C + LIS3MDL - Precision 9 DoF IMU](https://learn.adafruit.com/adafruit-lsm6ds3tr-c-lis3mdl-precision-9-dof-imu.md) - [CircuitPython Essentials](https://learn.adafruit.com/circuitpython-essentials.md) - [Adafruit MSA301 Triple Axis Accelerometer](https://learn.adafruit.com/msa301-triple-axis-accelerometer.md) - [Program CircuitPython USB Devices with iPhone & iPad](https://learn.adafruit.com/use-circuitpython-devices-with-iphone-ipad.md) - [MIDI Laser Harp with Time of Flight Distance Sensors](https://learn.adafruit.com/midi-laser-harp-time-of-flight-sensors.md) - [Making oscilloscope images with DACs](https://learn.adafruit.com/dac-oscilloscope-images.md) - [ePaper Maze Maker](https://learn.adafruit.com/epaper-maze-maker.md) - [Adafruit VCNL4040 Proximity Sensor](https://learn.adafruit.com/adafruit-vcnl4040-proximity-sensor.md) - [Lucio Blaster 2020 - CircuitPython for Advanced Prop Making](https://learn.adafruit.com/lucio-blaster-2020-circuitpython-advanced-prop-making.md) - [CircuitScheme - Lisp on CircuitPython](https://learn.adafruit.com/scheme-in-circuitpython.md) - [Use circup to easily keep your CircuitPython libraries up to date](https://learn.adafruit.com/keep-your-circuitpython-libraries-on-devices-up-to-date-with-circup.md) - [PermaProto Feather Case](https://learn.adafruit.com/permaproto-feather-case.md) - [A Logger for CircuitPython](https://learn.adafruit.com/a-logger-for-circuitpython.md) - [Humidity and Temperature Monitor with E-Ink Display](https://learn.adafruit.com/humidity-and-temperature-monitor-redux-e-ink-display.md) - [Adafruit AirLift Shield - ESP32 WiFi Co-Processor](https://learn.adafruit.com/adafruit-airlift-shield-esp32-wifi-co-processor.md) - [CircuitPython with Jupyter Notebooks](https://learn.adafruit.com/circuitpython-with-jupyter-notebooks.md)