Unity 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.

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

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.

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

Parts

An M0 or M4 board works best for this project, especially if you're using a stored calibration for the sensor. 

Angled shot of a Adafruit Metro M4 feat. Microchip ATSAMD51.
Are you ready? Really ready? Cause here comes the fastest, most powerful Metro ever. The Adafruit Metro M4 featuring the Microchip ATSAMD51. This...
Out of Stock
Angled shot of a Adafruit Feather M4 Express.
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,...
Out of Stock
Animation of Adafruit QT Py with onboard NeoPixel in a rainbow swirl.
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...
$7.50
In Stock
Overhead shot of long skinny black microcontroller connected to an OLED screen and a temperature-and-humidity sensor. The sensor data displays on the OLED.
One of our star development boards is the Adafruit METRO Mini 328, an excellent lil fellow that lets...
$14.95
In Stock
Angled shot of 9-DOF breakout board.
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...
$19.95
In Stock
Angled shot of STEMMA QT / Qwiic JST SH 4-pin Cable.
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...
$0.95
In Stock
1 x USB A to USB C Cable
Pink and Purple Woven USB A to USB C Cable - 1 meter long
1 x USB A to micro B Cable
Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

This guide was first published on Aug 31, 2022. It was last updated on 2022-08-31 11:34:37 -0400.

This page (Overview) was last updated on Aug 31, 2022.

Text editor powered by tinymce.