# Sensors in MakeCode

## Overview

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](https://learn.adafruit.com/makecode).

## 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``](https://makecode.adafruit.com/reference/input/on-gesture) 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``](https://makecode.adafruit.com/reference/input/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 .

![](https://cdn-learn.adafruit.com/assets/assets/000/042/385/medium800/circuit_playground_circuitplayground-screenshot_%282%29.png?1496827362)

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

- [Next Page](https://learn.adafruit.com/sensors-in-makecode/buttons.md)

## Featured Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Make It Talk](https://learn.adafruit.com/make-it-talk.md)
- [Pearl's Gem Weapon – Steven Universe](https://learn.adafruit.com/pearl-s-spear-steven-universe.md)
- [CPX Mystery Dreidel](https://learn.adafruit.com/cpx-mystery-dreidel.md)
- [How Tall Is It?](https://learn.adafruit.com/how-tall-is-it.md)
- [Compost Friend!](https://learn.adafruit.com/compost-optimization-machine.md)
- [DIY Circuit Playground Shields](https://learn.adafruit.com/circuit-playground-shields.md)
- [Make It Plot](https://learn.adafruit.com/make-it-graph-plot.md)
- [Installing Microsoft MakeCode for Adafruit](https://learn.adafruit.com/installing-makecode-for-adafruit.md)
- [How to Use Video Greenscreen in MakeCode](https://learn.adafruit.com/how-to-use-video-greenscreen-in-makecode.md)
- [Fidget Spinner Tachometer](https://learn.adafruit.com/fidget-spinner-tachometer.md)
- [Living Starry Night Painting](https://learn.adafruit.com/animated-starry-night-circuit-playground-express.md)
- [Circuit Playground Seashell Pendant](https://learn.adafruit.com/circuit-playground-seashell-pendant.md)
- [Getting Started With Steven Universe](https://learn.adafruit.com/getting-started-with-steven-universe.md)
- [CircuitPython Made Easy on Circuit Playground Express and Bluefruit](https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express.md)
- [Anatomical 3D Printed Beating Heart with MakeCode](https://learn.adafruit.com/anatomical-3d-printed-beating-heart-with-makecode.md)
