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.
Events vs live data
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 shake
event runs code when a shaking 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,
acceleration
gets 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 (acceleration
right).
Reference
Looking for the complete block reference, start at https://makecode.adafruit.com/reference/input .
Text editor powered by tinymce.