Build engaging programs for the BBC micro:bit using Microsoft's MakeCode web editor. Using this open source platform, you'll learn to program in an accessible way that easily translates into real-world programming.
BBC micro:bit Recipes is a practical guide with a problem-solving approach. It provides exact solutions for common application development problems for the micro:bit using MakeCode. You'll discover and apply techniques that can be used to build simple games with sprites, keep score, and control game play.
The micro:bit is a small programmable device that is a cross between a very small computer and a programmable embedded board. It is easy to program, extremely versatile, and designed with young learners in mind. In particular, it is designed to be easy for people who have never programmed before.
By the end of this book, you'll have the foundation to build programs with the Microsoft MakeCode editor and use and process data with the built-in sensors, such as accelerometer, compass, temperature, touch, and light. You'll also see how to work with communication protocols, such as Serial, I2C, and SPI and how to use variables, loops, logic, arrays, math and functions to easily solve problems.
Autorentext
Pradeeka Seneviratne is a software engineer with over 10 years of experience in computer programming and systems design. He is an expert in the development of Arduino and Raspberry Pi-based embedded systems and is currently a full-time embedded software engineer working with embedded systems and highly scalable technologies. Previously, Pradeeka worked as a software engineer for several IT infrastructure and technology servicing companies.
Pradeeka is an author of many books: Building Arduino PLCs [Apress], Internet of Things with Arduino Blueprints [Packt], Raspberry Pi 3 Projects for Java Programmers [Packt], Beginning BBC micro:bit [Apress], and Hands-on Internet of Things with Blynk [Packt].
Inhalt
Chapter 1: Getting in to programming with MakeCode
Chapter Goal: This chapter demonstrates some simple programs that can be built with MakeCode to provide context for what follows and introduces you to the Microsoft MakeCode online web editor.
- Using MakeCode editor
- Display text on the display, one character at a time
- Display text on the display, loop it over and over again
- Display numbers on the display, loop it over and over again
- Pauses the program for a number of milliseconds specified
- Displaying icons
Chapter 2: Displaying Images
Chapter Goal: This chapter presents how to display images and control LEDs on the micro:bit display. First, it shows how to display the built-in images. Then, it shows how to create custom images.
- Display built-in images
- Creating an image
- Creating a double-sized image
- Images offsetting
- Scrolling images
- Animating series of images
- Creating a flashing effect
- Stopping animation
- Displaying arrows
- Plotting a LED on the display
- Unpotting a LED on the display
- Toggling a LED
- Getting the state of the specified LED
- Displaying a vertical bar graph
- Clearing screen
- Plotting a LED on the screen with specified brightness
- Changing brightness of a LED
- Getting the brightness of a LED
- Turning on or off the display
Chapter 3: Inputs and Outputs
Chapter Goal: This chapter presents how to use buttons and pins on the micro:bit to handle inputs and outputs.
- Using built-in buttons as inputs
- Using external buttons
- Connecting LEDs
- Controlling LEDs
- Using potentiometer to control the brightness of a LED
- Mapping values
- Configuring PWM of the analog output
- Controlling servos
Chapter 4: Loops and Logic
Chapter Goal: The first part of this chapter guides you how to create loops to repeat things for specified number of times and do things while a condition is met. Finally, it presents how to use logical operations on values.
- Repeating a thing for specified number of times
- Run a sequence of actions while a condition is met
- If a value is true, then do some statements
- Check whether both inputs are equal each other
- Check whether both inputs are not equal each other
- Check whether both inputs true
- Check whether at least of the inputs is true
- Inverse an input
Chapter 5: Using Mathematical Functions
Chapter Goal: This chapter offers how to use the built-in mathematical functions to add, subtract, multiply, or divide numeric values, creating pseudorandom numbers, finding absolute value of a number, calculating remainder, finding max and min values, and convert ASCII characters to text.
- Adding numbers
- Subtracting numbers
- Multiplying numbers
- Dividing numbers
- Generating random numbers
- Generating true and false randomly
- Finding remainder
- Finding minimum and maximum value
- Finding absolute value of a number
- Converting ASCII characters to text
Chapter 6: Using Variables
Chapter Goal: This chapter presents how to use variables to hold data and use them. First, i...
Titel
BBC micro:bit Recipes
Untertitel
Learn Programming with Microsoft MakeCode Blocks
Autor
EAN
9781484249130
Format
E-Book (pdf)
Hersteller
Genre
Veröffentlichung
28.06.2019
Digitaler Kopierschutz
Wasserzeichen
Dateigrösse
14.88 MB
Anzahl Seiten
352
Unerwartete Verzögerung
Ups, ein Fehler ist aufgetreten. Bitte versuchen Sie es später noch einmal.