APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Accelerometer Model Element post and replies

Return to the Accelerometer Model Element thread
Login to post to this thread

JavaScript EjsS code examples on using Accelerometer Model Element
Afrânio Coelho Avatar
Afrânio Coelho
2 Posts

Hello,

We have an undergraduate project for creating an Ejss model by using the Accelerometer model element.
We wonder to buid a model that allows high school students to do experimental activities at home with their smartphones. For instance, they could use a smartphone as a pendulum bob to study harmonic oscillations or as a body in a free fall. So, have anyone ever made an ejss model that includes the Accelerometer model element? Could you send us the code in order to read and analyse it as an example?

Regards,

Afrânio
Brazil..


Replies to JavaScript EjsS code examples on using Accelerometer Model Element

Re: JavaScript EjsS code examples on using Accelerometer Model Element -
Wolfgang
192 Posts

Afrânio--  We do not yet have a model element to read phone sensors, such as the accelerometer, in EjsS.  You must write your own code, or import an external JavaScript library, to do this.



Re: Re: JavaScript EjsS code examples on using Accelerometer Model Element -
Afrânio Coelho Avatar
Afrânio Coelho
2 Posts

Dear Prof. Wolfgang,

As a matter of fact, we could not build a simulation for EjsS by using the so called Accelerometer Element. You are right, we need to develop such an interface in order to integrate it with EjsS. Unfortunately, as you can read from the other colleagues on this thread, the model suggested by Prof. Esquembre did not work.

I strongly suggest the OSP/EjsS community to colaborate in writing such a code interface. That could allow to build interesting EjsS simulations that could contribute to a active physics learning, even outside the school environment.

Thank you.



Re: Re: Re: JavaScript EjsS code examples on using Accelerometer Model Element -
Francisco Esquembre
237 Posts

Hello,

My example works for me with the iPad EjsS reader.

Are you using the iPad or the Android reader?

If the iPad, then maybe we did not upgraded it with this feature!

Anyway, I am currently working on creating simulations that can be made into Apps by using Cordova (or Ionic).

Paco



Re: Re: Re: Re: JavaScript EjsS code examples on using Accelerometer Model Element -
Wolfgang
192 Posts

The accelerometer example that Paco posted works on my Apple iPhone 5 when the example is run in the EjsS Reader available from the Apple iTunes store.  As Paco points out, you must use the Reader because a browser cannot access the local hardware due to security restrictions.

https://itunes.apple.com/es/app/ejss-reader-free/id870091579

The compiled app is attached to this post.  I do not have access to an Android device and would be most appreciative if someone would test this model in the Android Reader.

https://play.google.com/store/apps/details?id=org.colos.ejssreader.free

Attached File: ejss_model_AccelerometerElementExample.zip



Re: Re: Re: Re: Re: JavaScript EjsS code examples on using Accelerometer Model Element -
lookang Avatar
lookang
245 Posts

Yes. Android 5.1.1 Samsung note 3 running ejss reader or reader free cannot run the example properly.

See attached.

Attached File: Screenshot_2016-01-24-09-40-27.png


OSP@SG blog
OSP@SG Digital Library


Re: JavaScript EjsS code examples on using Accelerometer Model Element -
Francisco Esquembre
237 Posts

Afrânio,

Attached is an example that illustrates the use of the Accelerometer model element. HOWEVER, for this to work correctly, you must run the simulation using the EjsSApp (which you can get from iTunes or Google Play stores, the Free version would do). The app provides access to the hardware and passes it to our model element.

Trying to run the simulation as a regular web page will not work, since HTML pages cannot access the hardware for security reasons.

Hope this helps.

Paco

Attached File: ejss_src_AccelerometerElementExample.zip



Re: JavaScript EjsS code examples on using Accelerometer Model Element -
Hedler Barreto
2 Posts

Dear teacher Esquembre , I could not run the model . The graph of the accelerometer does not works. it seems that the model can not access the accelerometer. I run model with Ejss Reader pro. Please check. Thanks!

Hedler Barreto
Brazil

Post edited December 8, 2015 at 2:18 PM EST.



Re: Re: JavaScript EjsS code examples on using Accelerometer Model Element -
lookang Avatar
lookang
245 Posts

I confirm the model is not working.
It says accelerometer not present.

Attached File: Screenshots_2015-12-12-22-29-20.png


OSP@SG blog
OSP@SG Digital Library


Re: Re: Re: JavaScript EjsS code examples on using Accelerometer Model Element -
Hedler Barreto
2 Posts

The ejssreader can not start the accelerometer . I've tried using the Set function but does not start.



Re: JavaScript EjsS code examples on using Accelerometer Model Element -
Wolfgang
192 Posts

The Accelerometer example works in the iOS EJS Reader app on both iPads and iPhones.   As shown in the attached screen shot, the app displays an arrow that indicates the direction of the acceleration and the vector components of the acceleration.  Please make sure that you are running the Reader version 3.01.06 or above.

Attached File: Accelerometer.PNG



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book