Skip to first unread message

lv lv

unread,
Mar 30, 2018, 4:07:51 PM3/30/18
to MIT App Inventor Forum

How do you make this orientation sensor app? It has to have the same design and the colors must change depending on the direction of your phone. I dont even know where to start can anyone help?

SteveJG

unread,
Mar 30, 2018, 4:17:37 PM3/30/18
to mitappinv...@googlegroups.com
Here is the Orientation sensor documentation  http://ai2.appinventor.mit.edu/reference/components/sensors.html#OrientationSensor  It is a beginning.

Then there are these 
  • Chapter 5. Ladybug Chase
  • All use the Orientation Sensor and perhaps will give you ideas.  They probably do not do exactly what you need to do so you will have to do some programming.
This one might be similar  http://appinventor.pevest.com/?p=205




We want you to have fun with App Inventor so here are some resources to help you learn to use the AI2 tools  A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  

How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .


What have you tried?  ... 



Regards,
Steve

lv lv

unread,
Mar 30, 2018, 5:24:56 PM3/30/18
to MIT App Inventor Forum
I have tried to find a tutorial to do this app but I can only find the other ones which dont really explain anything on the color changing depending on the phones movement appp

SteveJG

unread,
Mar 30, 2018, 7:15:31 PM3/30/18
to mitappinv...@googlegroups.com
The color changing can be done using conditional statements like  If else then    and Logic blocks  along with the movement of the phone .  You are right, there is not a tutorial that will show exactly how to do this that I am aware.  You have to build it.   If you show what you tried by posting a block image, you will get advice from the experts.  If you read the Inventor's Manual mentioned in a previous post (it takes about an hour) you might not need any help.

How to use the If statement is here 

Buttons have a color property.    When the phone tilts one way, perhaps make the   Button.Color = Red.   when tilted another way   Button.Color = Blue perhaps.  I think in your posted image, you a changing the colors of the Labels's based on the phone's attitude.  You will do that with a fancy conditional statement.

If OrientationSensor.Azimuth = 0 then Button.Color = Red  else if OrientationSensor.Azimuth = 90 then Button.Color = Blue   might work.    The exact coding might be a little different.   Instead you may have to use a range of azimuth values instead of an Integer.     For example ... If OrientationSensor.Azimuth > 45 and OrientationSensor.Azimut < 90 then Button.Color = Green.


Try some blocks, show us what you tried and you will get specific advice.  You have to do some of the work.

Reply all
Reply to author
Forward
0 new messages