on Gesture

Run some code when you perform a gesture, like shaking the Adafruit Circuit Playground Express.

input.onGesture(Gesture.Shake,() => {
})

Parameters

  • gesture: the gesture to detect. A gesture is the way you hold or move the Adafruit Circuit Playground Express. Gestures are:
    • shake: shake the board
    • logo up: the logo is facing up
    • logo down: the logo is facing down
    • screen up: the screen side is up
    • screen down: the screen side is down
    • tilt left: the board is tilted to the left
    • tilt right: the board is tilted to the right
    • free fall: the board is falling for a distance
    • 2g: acceleration force of 2 g (works well for step detection)
    • 3g: acceleration force of 3 g
    • 6g: acceleration force of 6 g
  • body: code to run when the gesture event occurs

Example: random number

Log a message when you shake the Adafruit Circuit Playground Express.

input.onGesture(Gesture.Shake, function() {}
    console.log("I'm shaking!")
})

accelerometer