This is an old revision of the document!

Accelerometer sensor and how to use it

(Updated 08 december 2016)

With the accelerometer we can interpret the velocity of the Pillo sensor over the X, Y and Z axes.


GetAcceleroX (PilloID);
GetAcceleroY (PilloID);
GetAcceleroZ (PilloID);

PilloID: the ID of the connected Pillo.

using UnityEngine;
using System.Collections;
using Pillo;
using UnityEngine.UI;

public class acceleroScript : MonoBehaviour 
	private float AcceleroX, AcceleroY, AcceleroZ;
	public PilloID Pillo1;

	// Update is called once per frame
	void Update () 
		//Retrieving the Accelerometer values from the receiver and saving them in a variable.
		AcceleroX = PilloController.GetAcceleroX (Pillo1);
		AcceleroY = PilloController.GetAcceleroY (Pillo1);
		AcceleroZ = PilloController.GetAcceleroZ (Pillo1);

		print ("AcceleroX: " + AcceleroX);
		print ("AcceleroY: " + AcceleroY);
		print ("AcceleroZ: " + AcceleroZ);

If you would like to know how to use this function in a game, please take a look at this tutorial.