Basic Spirit Level

Good day,
Is it possible with App Inventor to make a Spirit level app using the sensors? Or is there an extension that I could use for that?


You may use Acceleration Meter in the sensors.

Thanks. any links to tutorials? I have no idea where to start. Can't find anything on Youtube yet. Only for shaking dices, ect.

Ok I will send images

Check this block to get the X, Y and Z Acceleration-
In a canvas try to move a image sprite for your acceleration.

Ok, I'e tried this:

No luck yet. Will play around

Is this what you want to do Johan?

This solution is possible if your device has an Orientation Sensor (not all Androids do).

Together with the Bike Setup app, the saddle of the bike should be set level. So I would like to include a simple "bubble level" so when you place the device on the saddle, it indicates if level or not.

Based upon

  • xAccel : 0 when the phone is at rest on a flat surface, positive when the phone is tilted to the right (i.e., its left side is raised), and negative when the phone is tilted to the left (i.e., its right size is raised).
  • yAccel : 0 when the phone is at rest on a flat surface, positive when its bottom is raised, and negative when its top is raised.

this simple code should work to work as a level. Bubble level? Well experiment with a Ball on a Canvas. You might be able to convert the logic to that. At the moment, the app displays a green Text when the Android sets face up on a flat surface and red for anything else. Last time I looked, the bicycle seat was anything but flat but do what you got to do.

decrease sensitivity by increasing the threshold acceleration from 0.2 to a little higher. Every device probably will produce slightly different 'accelerations'. This works with my Android 8.1 tablet.

1 Like

Thanks, will experiment.
Herewith a similar app, but a standalone saddle adjuster. Yes a saddle is not flat, but, placing a hardcover book on a saddle make it easier :slight_smile:

Got this to work, used the Ortientation sensor :slight_smile:

Is there a way to adjust the sensitivity? I have used a multiplier to increase the rate of the indication, but with that the sensitivity increase as well. so the ball is not steady but bounces slightly around all the time.

Maybe something like this:

1 Like