How can we convert the default 'Local Variables' of some extensions into 'Global Variables'?

When I tried to use different sensors in the same project, I can see the default yellow blocks of extensions (ie, found in Top) that carry variables within. But, to create an example project that detects is a person walks or drives, I need to use the variables from both sensors within 'if-then' statements.

ie, if pedometor sensor senses as if the person is not walking AND if location sensor detects as if a person is moving, then the app has to display 'You are Driving'.

But, when we check the blocks, these variables are packed within the yellow blocks as local variable. So, we are unable to use these variable data of different sensors and put it within 'if statements/conditions'. We are in a compulsion to use the variables only within the yellow blocks of the same sensor. The sensor data from many sensors cannot be used together.

This is my understanding as a newbie. Please, guide me. Thanks.

You can copy those local variables to a global variable inside those event blocks...For example:

1 Like

Can you give tips to achieve this?

  1. If Location sensor speed is (> 10 m/s & < 15 m/s) for 10 mins, then say 'TextToSpeech-Smooth Driving'. The concept is if a driver maintains normal speed, then a message 'Smooth Driving' has to be played.
  2. Start Player (music- You-Started-Driving.mp3) only if Location Sensor (speed >10 m/s and (< 1 m/s for past 5 minutes)). The concept of second point is that If a driver is not driving for 5 minutes and if he begins to drive after that, a music has to be played.

Have you read this so you understand how the 'speed' property works? A Basic LocationSensor Speedometer
If not do so immediately and also read Programming Your App to Make Decisions (the section on making Complex Conditions and Programming Conditions within a Condition,

Once you do understand, make a decision on whether this is going to work or not.

Incidentally, To convert m/sec to mph, Multiply the rate of meters per second by 2.2369. Example: 30 meters per second times 2.2369 equals 67.107, so 30 meters per second equals 67.107 miles per hour. (10m/s + 22.4 mph)

1 Like

I experimented, something like this.

But, player is playing music as soon as the app is opened.

Because you left Clock2 enabled in the Designer?

1 Like