© Pradeeka Seneviratne  2019
Pradeeka SeneviratneBBC micro:bit Recipeshttps://doi.org/10.1007/978-1-4842-4913-0_12

12. Using Sensors

Pradeeka Seneviratne1 
(1)
Udumulla, Mulleriyawa, Sri Lanka
 

This chapter presents how to use sensors with micro: bit to sense the physical environment. It has some built-in sensors such as accelerometers, compasses, temperatures, lights, and touch. You can use them without attaching any external components to your micro:bit.

12-1. Using Built-In Accelerometer

Problem

You want to get the acceleration values in the left and right direction (x-axis).

Solution

  • In the Toolbox, click on the Basic category. Then click and drag the show number block over, and place it inside the forever block.

  • In the Toolbox, click on the Input ...

Get BBC micro:bit Recipes: Learn Programming with Microsoft MakeCode Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.