Appendix A

JavaScript Blocks Recipes

THIS APPENDIX CONTAINS complete code listings for the programs detailed in Chapter 6, ‘JavaScript’, and Chapter 8, ‘The Wireless BBC micro:bit’. These can be entered into the JavaScript Blocks Editor visually. Or, you can enter the alternative versions from Appendix B, ‘JavaScript Recipes’, in JavaScript Mode, and then use the Editor toggle to switch back to JavaScript Blocks Mode (see Chapter 6.)

Chapter 6: Hello, World! (Non-looping)

image

Chapter 6: Hello, World! (Looping)

image

Chapter 6: Button Inputs (Single Button)

image

Chapter 6: Button Inputs (Two Buttons)

image

Chapter 6: Touch Inputs

image

Chapter 6: Temperature Sensor (No Formatting)

image

Chapter 6: Temperature Sensor (with Formatting)

image

Chapter 6: Compass Sensor

Chapter 6: Accelerometer ...

Get The Official BBC Micro:bit User Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.