1

I'm currently trying to learn the AppInventor2 tool, by coding a roll and pitch application similar to the one listed in app Inventor gallery (Balance Meter).

What I want to do, is enhancing the rolling from the OrientationSensor, by triggering a sound on certain values reached.

So far I know that the rolling is marked from -90 to 90 degrees. Although I have declared a lower value e.g. 30 to 35 degrees, I get the sound triggered only on the leftwards rolling of the device, but not on the other side. I want it to be triggered when rolling occur form e.g. -30 to 35 degrees respectively.

The following image shows the blocks I've used:

enter image description here

Need to mention that orientation of app is in landscape mode only, with home button on right side.

Could anyone be kind enough to give me a clue to the right blocks to use, or to the logic I should be followed to make this work? Thank you all in advance for your answers.

CodeBugging
  • 321
  • 12
  • 28

1 Answers1

1

instead of the random integer block just use an or block to play sound if roll > 30 or roll < -30

enter image description here

or if you only want to play the sound if roll is between -35 and -30 or between 30 and 35

enter image description here

Taifun
  • 6,165
  • 17
  • 60
  • 188
  • Thanks @Taifun for your answer. Have tried both, with great success on the second version with a little modification to much my needs. Problem is it's not functional on the "pitch". Is it because I'm using the "AccelerometerSensor" reading the "zAccel" for the pitch or what? – CodeBugging Mar 25 '15 at 22:07
  • without a screenshot I unfortunately have to say: *sorry, I don't know*... probably [this snippet](https://puravidaapps.com/snippets.php#2accelerometer) can help? What about accepting this answer and starting a new question with your new question and add a screenshot there? – Taifun Mar 25 '15 at 22:35
  • your answer is accepted. Don't know if it is ok to repost a similar question with the "pitch" problem in the "zAccel" sensor, but if it is ok, I will post a screenshot too, if you are kind enough to help me out again. – CodeBugging Mar 25 '15 at 23:03
  • guess your are right. Posted a new question [link]http://stackoverflow.com/questions/29268426/event-driven-sign-with-pitch-in-app-inventor-2 – CodeBugging Mar 25 '15 at 23:28