0

Since I'm new to App Inventor2 tool, I'm having a little issue trying to get a "pitch" value to trigger the visibility of a label.

I need to have a label being shown when the "AccelerometerSensor", reaches the -30 or 30 degrees point. To make this happen I'm using the "zAccel" value and the app runs in landscape mode, with the home button on the right side of the android device.

The following image shows the blocks I've used so far, without much success, as the "Warning" is visible all the time:

enter image description here

Any help with a block or a clue in the logic used, will be much appreciated. Thank you all in advance for your time and answers.

CodeBugging
  • 321
  • 12
  • 28
  • what about `>30` or `<-30`? Also i would add an `else` to set the warning to false... – Taifun Mar 25 '15 at 23:34
  • @Taifun, thank you for your tip, answer marked as correct. Changing value from (<30 or >-30) to your suggestion (>30 or <-30) did the trick! Can you explain though, what I was setting wrong in my blocks? Could you also direct me on how can I access the "Accelerometer" settings through coding to let user calibrate it to "0" on app start, and change the sensitivity of sensor too? – CodeBugging Mar 25 '15 at 23:50
  • Well, if you do not use an `else` statement, once the warning is visible, it will stay visible. Sorry, I don't know about how to calibrate the accelerometer. – Taifun Mar 27 '15 at 13:56

1 Answers1

0

let me provide my given comments as answer now:

You should use >30 or <-30 instead, because else the if statement always is true.
Also I would add an else statement to set the warning back to false again. If you do not do this, once the warning is visible, it will stay visible.

Taifun
  • 6,165
  • 17
  • 60
  • 188