Pedometer with Itoo

In this tutorial we will learn how to program an app that counts the steps we take continuously thanks to the Itoo extension

For this we will use the following components

componentes

NotifyBasic is its own extension to create a notification that gives us data on steps and distance traveled.

First we start the service from Screen1.Initialize

Next we start the pedometer and register the Pedometer1.WalkStep event

We tell the service what to do when it detects a new step

procedures_defnoreturn

Let's now break down the blocks that this procedure contains

We create the notification to inform us of the steps and distance traveled

We save the pedometer data

savepedo

The application will not save the step data day by day, so we need to create a database with all the dates. If the variable "listafechas" does not exist, it will create it.

We also access the "fecha" variable that will indicate the date saved in yyyy/MM/dd format so we can compare it with today's date, to be able to reset the pedometer.

If the current date does not match the saved date, reset the pedometer and update the variables "listafechas" and "fecha"

Create or update the variable with the current date, creating or updating a list with steps and distance

For every 1000 steps the program gives a voice warning

With the variables "listafechas" and the data saved daily by the service, a database is created that is displayed in a Listview

It is important to note that for the service to function correctly on Xiaomi or Samsumg phones, it is necessary that the battery saving is marked as "No Restrictions"

ServicioIto.aia (126.3 KB)

The application works with the Pedometer component of App Inventor, this component works with the accelerometer, which although quite reliable, does not have the same reliability as if our phone has a step sensor, it is also accompanied by what uses the phone's step sensor .

StepssdItoo.aia (139.2 KB)

Un saludo

4 Likes

4 posts were split to a new topic: I need another extension NotifyBasic, which is not published