Just like the other sensors, the accelerometer has the data
and change
events. These are particularly useful because they allow you to constantly track the updated values of the accelerometer, like the orientation.
Event | Description |
---|---|
data |
Fires every 100ms to check for data from the accelerometer. |
change |
Fires whenever the accelerometer detects a change in motion. This checks to see if the current data from sensor is the same as it was 100ms ago. If this is the case, the event won't trigger. Otherwise, the event triggers. |
shake |
Fires whenever the board is shaken. |
Sometimes we don't care what the orientation of the board is, we just cared that it moved at all. This is where events like change
and shake
come in.
Found a bug in the documentation? Let us know at documentation@code.org