# rotationX on Android

**URL:** <https://discourse.processing.org/t/rotationx-on-android/34479>\
**Category:** Coding Questions\
**Created:** [January 5, 2022, 1:45pm UTC](https://discourse.processing.org/t/rotationx-on-android/34479 "2022-01-05T13:45:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katarzyna](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@Katarzyna](https://discourse.processing.org/u/Katarzyna)\
**Post date:** [January 5, 2022, 1:45pm UTC](https://discourse.processing.org/t/rotationx-on-android/34479/1 "2022-01-05T13:45:55Z")

</div>

I try with Accelerometer data on Android device. In script

```auto
function setup() {
  createCanvas(100, 100);
}

function draw() {
  background(200);
  console.log(rotationX)
}

```

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 5, 2022, 3:16pm UTC](https://discourse.processing.org/t/rotationx-on-android/34479/2 "2022-01-05T15:16:33Z")

</div>

Maybe you should be in webgl mode

```auto
createCanvas(100, 100, WEBGL);

```

> **[reference | p5.js](https://p5js.org/reference/#/p5/rotationX)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

---

<div class="post-metadata">

**Author:** ![Katarzyna](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@Katarzyna](https://discourse.processing.org/u/Katarzyna)\
**Post date:** [January 5, 2022, 3:59pm UTC](https://discourse.processing.org/t/rotationx-on-android/34479/3 "2022-01-05T15:59:08Z")

</div>

Unfortunately, it doesn’t help.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 6, 2022, 10:11am UTC](https://discourse.processing.org/t/rotationx-on-android/34479/4 "2022-01-06T10:11:56Z")

</div>

The word null or the number 0 ??

Did you try other variables such as rotationZ or

> **[reference | p5.js](https://p5js.org/reference/#/p5/deviceOrientation)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

---

<div class="post-metadata">

**Author:** ![Katarzyna](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@Katarzyna](https://discourse.processing.org/u/Katarzyna)\
**Post date:** [January 7, 2022, 8:23am UTC](https://discourse.processing.org/t/rotationx-on-android/34479/5 "2022-01-07T08:23:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 7, 2022, 1:39pm UTC](https://discourse.processing.org/t/rotationx-on-android/34479/6 "2022-01-07T13:39:29Z")

</div>

Is this your entire Sketch or are there more lines?

You cannot have a variable of the same name for example

---

<div class="post-metadata">

**Author:** ![Katarzyna](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@Katarzyna](https://discourse.processing.org/u/Katarzyna)\
**Post date:** [January 8, 2022, 9:35pm UTC](https://discourse.processing.org/t/rotationx-on-android/34479/7 "2022-01-08T21:35:32Z")

</div>

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

> **[reference | p5.js](https://p5js.org/reference/#/p5/rotationX)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 8, 2022, 11:25pm UTC](https://discourse.processing.org/t/rotationx-on-android/34479/8 "2022-01-08T23:25:24Z")

</div>

Hello @Katarzyna,

The example works on my Android phone with Google Chrome:  
[https://p5js.org/reference/#/p5/rotationX](https://p5js.org/reference/#/p5/rotationX)

Steps:

- I created a quick sketch here on PC with my account:  
[https://editor.p5js.org/](https://editor.p5js.org/)
- 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.

`:)`
