# Accelerometer Script

**URL:** <https://forum.inductiveautomation.com/t/accelerometer-script/77114>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 30, 2023, 11:26pm UTC](https://forum.inductiveautomation.com/t/accelerometer-script/77114 "2023-07-30T23:26:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Finn\_Witney](https://avatars.discourse-cdn.com/v4/letter/f/f04885/32.png) [@Finn\_Witney](https://forum.inductiveautomation.com/u/Finn_Witney)\
**Post date:** [July 30, 2023, 11:26pm UTC](https://forum.inductiveautomation.com/t/accelerometer-script/77114/1 "2023-07-30T23:26:54Z")

</div>

New to ignition and wanting to use the accelerometer feature to change to a different perspective view upon the phone being shook by the user. Can get values to be displayed using the example given from inductive automation, however im now stuck on trying to get it to change views when any of the readings are above 12/13. Would appreciate any pointers or ideas.

 ![Screenshot 2023-07-31 090716](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/381cefbb2631bb20043478c2af9dfd91d4559aae.png)

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [July 30, 2023, 11:48pm UTC](https://forum.inductiveautomation.com/t/accelerometer-script/77114/2 "2023-07-30T23:48:11Z")

</div>

You are turning those x,y,z values into a string. They need to stay numeric.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [July 30, 2023, 11:49pm UTC](https://forum.inductiveautomation.com/t/accelerometer-script/77114/3 "2023-07-30T23:49:37Z")

</div>

You could "simplify“ using `x^2` as well instead of `x * x` 🤷

---

<div class="post-metadata">

**Author:** ![Finn\_Witney](https://avatars.discourse-cdn.com/v4/letter/f/f04885/32.png) [@Finn\_Witney](https://forum.inductiveautomation.com/u/Finn_Witney)\
**Post date:** [July 31, 2023, 12:25am UTC](https://forum.inductiveautomation.com/t/accelerometer-script/77114/4 "2023-07-31T00:25:28Z")

</div>

Yeah cool ill change that and see if it does anything 👍

---

<div class="post-metadata">

**Author:** ![Finn\_Witney](https://avatars.discourse-cdn.com/v4/letter/f/f04885/32.png) [@Finn\_Witney](https://forum.inductiveautomation.com/u/Finn_Witney)\
**Post date:** [July 31, 2023, 2:07am UTC](https://forum.inductiveautomation.com/t/accelerometer-script/77114/5 "2023-07-31T02:07:04Z")

</div>

![12](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/d/fd5ba0a203046215f9755d6c95fc2c70aeff1e93.png)

is just using the ['z'] value and seeing if its above 13 the right way to go about it?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [July 31, 2023, 3:29am UTC](https://forum.inductiveautomation.com/t/accelerometer-script/77114/6 "2023-07-31T03:29:30Z")

</div>

I see a nesting issue. This:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/8/d87c4a37f870ae9fdd9c75ab3b1f8c21a7ac97cf.png)  
Should be this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/8/f82265acb33b7fa2bfdd5405a1df21d9dd8076ac.png)  
...or perhaps just this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/b/2bb4eac54a9e64a73295ff6dd23c37c21a189c0f.png)  
I don't understand this line of code because it's just a list with a string and compared to an integer :  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/3/f39f0389bc904c8ce8157653bd6e2ecde789b290.png)  
Perhaps it should be this?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/0/b0d864a29af3b35b7305d959c1b2013a9016ae56.png)
