Problem With Magnetometer Sensor Event

This simple app involves my son running up and down the stairs and touches his phone to a magnet every time.

The problem is that although I want a sound to play when the absolutestrength is over 150, the sound keeps playing continuously. I have attached blocks. Thank you.

In case anyone was wondering,

the uds variable is how many times the magnet has gone over 125 strength and chimed variable is to make sure the sound doesn't play more than once

My guess is that the magnetic filed is changing many times (and is greater than 125) and only doesn't call the sound to play when uds does not equal 6, but will call it when uds equals 7, 8, 9.....

You may need to introduce a clock timer, to prevent additional calls / changes from firing.

My guess is that the magnetic filed is changing many times (and is greater than 125) and only doesn't call the sound to play when uds does not equal 6, but will call it when uds equals 7, 8, 9.....

I tried this by adding a label that always shows the strength. No luck. Always below 40, uds below 6 always also.

How would that help?

Can you share your aia project here, for testing ?

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.
export_and_upload_aia

Sure. I have more than one screen, so I have added a button to go directly to the screen for you to test.
error. reuploading
Thank you.

New file below.
FunExercise (1).aia (882.4 KB)

Patience please :wink:

Try something like this:

image

How does this work ?

  1. Phone touches magnet and gets reading greater than 125
  2. Records the reading, disables the sensor, plays the sound
  3. Starts the clock (I used 3000ms to give time enough to move phone away from magnet)
  4. When the clock fires, enable the sensor, ready to detect again

Thank you so much! Will try out and test. Thanks for the speedy response and testing.

Solved. A sound from another screen was interfering. However, I will keep @TIMAI2's code as solution.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.