The Adafruit Circuit Playground Express comes packed with built-in sensors. This guide will show you how to leverage them in Microsoft MakeCode. If you are new to MakeCode, make sure to read the MakeCode primer.
You can use a sensor through events or by reading the live data.
Events allow to register code that runs when a particular pattern is detected. For example, the
on shakeevent runs code when a shacking gesture is detected by the accelerometer. You can mix and match events from different sensors in the same program but each event type can only be registered once.
Live data gets a live (or slightly filtered) reading of the sensor data. For example,
accelerationgets an immediate reading from the accelerometer.
The block code below show the 2 style of programming with sensors. Through events (
on shake left) or in the traditional loop style with live data (
Looking for the complete block reference, start at https://makecode.adafruit.com/reference/input .