BBC micro:bit Recipes, 1st ed.
Learn Programming with Microsoft MakeCode Blocks

Author:

Language: Anglais

Approximative price 31.64 €

In Print (Delivery period: 15 days).

Add to cartAdd to cart
Publication date:
280 p. · 15.5x23.5 cm · Paperback
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 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. 

What You'll Learn
  • Display text, images, and animations on the micro:bit display
  • Connect external sensors and process data
  • Make and play music through speakers and headphones
  • Use Bluetooth service to communicate with Smartphones and tablets

Who This Book Is For

Those who are interested in learning to program the BBC micro:bit with Microsoft MakeCode. The difficulty level falls from beginner to intermediate level.
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. 
  1. Using MakeCode editor
  2. Display text on the display, one character at a time
  3. Display numbers on the display, one number at a time
  4. Display text on the display, loop it over and over again
  5. Display numbers on the display, loop it over and over again
  6. Pauses the program for a number of milliseconds specified
  7. 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.
  1. Display built-in images
  2. Creating an image
  3. Creating a double-sized image
  4. Images offsetting
  5. Scrolling images
  6. Animating series of images
  7. Creating a flashing effect
  8. Stopping animation
  9. Displaying arrows
  10. Plotting a LED on the display
  11. Unpotting a LED on the display
  12. Toggling a LED
  13. Getting the state of the specified LED
  14. Displaying a vertical bar graph
  15. Clearing screen
  16. Plotting a LED on the screen with specified brightness
  17. Changing brightness of a LED
  18. Getting the brightness of a LED
  19. 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.  
  1. Using built-in buttons as inputs
  2. Using external buttons
  3. Connecting LEDs
  4. Controlling LEDs
  5. Using potentiometer to control the brightness of a LED
  6. Mapping values
  7. Configuring PWM of the analog output
  8. 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.
  1. Repeating a thing for specified number of times
  2. Run a sequence of actions while a condition is met
  3. If a value is true, then do some statements
  4. Check whether both inputs are equal each other
  5. Check whether both inputs are not equal each other
  6. Check whether both inputs true
  7. Check whether at least of the inputs is true
  8. 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.
  1. Adding numbers
  2. Subtracting numbers
  3. Multiplying numbers
  4. Dividing numbers
  5. Generating random numbers
  6. Generating true and false randomly
  7. Finding remainder
  8. Finding minimum and maximum value
  9. Finding absolute value of a number
  10. 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, it shows how to declare different type of variables by initializing them with different type of data. Then, it shows how to get data from variables and process them. Finally, it shows how to change data in variables.
  1. Creating an integer variable
  2. Creating a floating-point variable
  3. Creating a string variable
  4. Taking data out from variables
  5. Changing the value of the variable
  6. Changing the value of the variable by a specified value
Chapter 7: Functions and Arrays
Chapter Goal: This chapter introduces functions and arrays. First, it offers how to build functions to reuse the code. Finally, it presents how to create arrays for different data types (integers and string) and show what are things can do with arrays.
  1. Creating a function
  2. Creating an array with numbers
  3. Creating an array with strings
  4. Finding the number of elements in an array
  5. Getting the value at the given index in an array
  6. Setting the value at the given index
  7. Appending a new element to an array
  8. Removing the last element from an array
  9. Removing the first element from an array
  10. Returning the index of the first occurrence of a value in the array
  11. Reversing the element in an array
Chapter 8: Playing Music
Chapter Goal: This chapter presents how to generate music from the micro:bit. First, it guides how to prepare the hardware for music by attaching a speaker or headphone to the micro:bit pin 0 or different pin. Then, it shows how to play some built-in melodies. After that it covers the fundamentals of music such as tones (notes), beats, tempo, and rest. Next, it presents how build your own melodies based on the fundamentals of music. Finally, it shows how to do something on various melody events.
  1. Connecting a speaker to the pin 0
  2. Connecting speaker to a different pin
  3. Connecting a headphone
  4. Playing a built-in melody
  5. Playing a tone (note)
  6. Playing a tone for the given duration
  7. Rests for the specified time
  8. Making melodies
  9. Get the frequency of a note
  10. Get the duration of the beat
  11. Get the tempo in beat
  12. Change tempo by the specified amount
  13. Set tempo to the specified amount
  14. Do something on various melody events
Chapter 9: Using Sensors
Chapter Goal: This chapter presents how to use sensors with micro:bit to detect physical environment. First, it will show how to use the built-in sensors such as accelerometer, compass, temperature (internal), light (not accurate), and touch. Finally, it will show how to use some external sensors such as light (accurate), temperature (external), moisture, and motion sensor with micro:bit.
  1. Using Internal sensors
  • Accelerometer
  • Compass
  • Temperature
  • Light
  • Touch
  1. Using External sensors
  • Light
  • Temperature
  • Moisture
  • Motion
Chapter 10: Using Bluetooth Service
Chapter Goal: This chapter presents how to use Bluetooth service to connect with smartphones
  1. Installing micro:bit app
  2. Pairing micro:bit with smartphone
  3. Using accelerometer service
  4. Using button service
  5. Using I/O pin service
  6. Using LED service
  7. Using temperature service
  8. Using magnetometer service
  9. Using UART service
  10. Creating Eddystone beacons
Chapter 11: Using Radio
Chapter Goal: This chapter presents how to use the built-in radio to wirelessly broadcast and exchange data between micro:bits.
  1. Creating radio groups
  2. Setting transmission power
  3. Transmitting serial number
  4. Sending numeric data
  5. Sending text
  6. Receiving data
  7. Writing received packet to serial
Chapter 12: Using Serial and I2C Communication
Chapter Goal: This chapter presents how to use Serial, I2C, and SPI communication protocols to exchange data between micro:bit and other devices. 
  1. Printing a line of text to the serial port
  2. Printing a numeric value to the serial port
  3. Writing a name-value pair as a line to the serial port
  4. Sending a piece of text through the serial connection
  5. Printing an array of numeric values as a CSV to the serial port
  6. Reading a line of text from the serial port
  7. Reading the received data as a string
  8. Setting the serial input and output to use pins
  9. Reading data through I2C
  10. Writing data through I2C
  11. Reading data through SPI
  12. Writing data through SPI
Chapter 13: Building Simple Games
Chapter Goal: This chapter presents how to develop simple games with sprites, keep score and control gameplay.
  1. Creating a sprite in the game engine
  2. Deleting a sprite from the game engine
  3. Moving the sprite
  4. Turning the sprite
  5. Detecting edges and bouncing
  6. Getting, setting, and changing the properties of the sprite
  7. Touching
  8. Maintaining score
  9. Controlling gameplay (count down, game over, pause, resume)
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].
Learn how to program the BBC micro:bit with MakeCode and easy-to-follow steps

Understand exact solutions for common programming problems

Use few hardware (and affordable) to build example projects