rotationX on Android

I try with Accelerometer data on Android device. In script

function setup() {
  createCanvas(100, 100);

function draw() {

there is only a null. Why should I do to get value of rotationX?

1 Like

Maybe you should be in webgl mode

createCanvas(100, 100, WEBGL);

Unfortunately, it doesn’t help.

The word null or the number 0 ??

Did you try other variables such as rotationZ or

It is null. RotationY and Z doesn’t work either. Any other ideas?

Is this your entire Sketch or are there more lines?

You cannot have a variable of the same name for example

It is a fragment of bigger script, but it should work separately.
In manual there is similar one:

Hello @Katarzyna,

The example works on my Android phone with Google Chrome:


  • I created a quick sketch here on PC with my account:
  • I added a console.log(rotationX);
  • Saved it.
  • Created a link to share and e-mailed it to myself.
  • Opened it on my phone when I received it.
  • I was delighted seeing a rotating box and the values showing on the console.