
BBC micro:bit Recipes: Learn Programming with Microsoft MakeCode Blocks
Pradeeka Seneviratne
Résumé
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.
- Using MakeCode editor
- Display text on the display, one character at a time
- Display numbers on the display, one number 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 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
- 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
- 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
- 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
- Creating an integer variable
- Creating a floating-point variable
- Creating a string variable
- Taking data out from variables
- Changing the value of the variable
- Changing the value of the variable by a specified value
- Creating a function
- Creating an array with numbers
- Creating an array with strings
- Finding the number of elements in an array
- Getting the value at the given index in an array
- Setting the value at the given index
- Appending a new element to an array
- Removing the last element from an array
- Removing the first element from an array
- Returning the index of the first occurrence of a value in the array
- Reversing the element in an array
- Connecting a speaker to the pin 0
- Connecting speaker to a different pin
- Connecting a headphone
- Playing a built-in melody
- Playing a tone (note)
- Playing a tone for the given duration
- Rests for the specified time
- Making melodies
- Get the frequency of a note
- Get the duration of the beat
- Get the tempo in beat
- Change tempo by the specified amount
- Set tempo to the specified amount
- Do something on various melody events
- Using Internal sensors
- Accelerometer
- Compass
- Temperature
- Light
- Touch
- Using External sensors
- Light
- Temperature
- Moisture
- Motion
- Installing micro:bit app
- Pairing micro:bit with smartphone
- Using accelerometer service
- Using button service
- Using I/O pin service
- Using LED service
- Using temperature service
- Using magnetometer service
- Using UART service
- Creating Eddystone beacons
Chapter Goal: This chapter presents how to use the built-in radio to wirelessly broadcast and exchange data between micro:bits.
- Creating radio groups
- Setting transmission power
- Transmitting serial number
- Sending numeric data
- Sending text
- Receiving data
- Writing received packet to serial
Chapter Goal: This chapter presents how to use Serial, I2C, and SPI communication protocols to exchange data between micro:bit and other devices.
- Printing a line of text to the serial port
- Printing a numeric value to the serial port
- Writing a name-value pair as a line to the serial port
- Sending a piece of text through the serial connection
- Printing an array of numeric values as a CSV to the serial port
- Reading a line of text from the serial port
- Reading the received data as a string
- Setting the serial input and output to use pins
- Reading data through I2C
- Writing data through I2C
- Reading data through SPI
- Writing data through SPI
Chapter Goal: This chapter presents how to develop simple games with sprites, keep score and control gameplay.
- Creating a sprite in the game engine
- Deleting a sprite from the game engine
- Moving the sprite
- Turning the sprite
- Detecting edges and bouncing
- Getting, setting, and changing the properties of the sprite
- Touching
- Maintaining score
- Controlling gameplay (count down, game over, pause, resume)
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].
Caractéristiques techniques
PAPIER | |
Éditeur(s) | Apress |
Auteur(s) | Pradeeka Seneviratne |
Parution | 01/07/2019 |
Nb. de pages | 352 |
EAN13 | 9781484249123 |
Avantages Eyrolles.com
Consultez aussi
- Les meilleures ventes en Graphisme & Photo
- Les meilleures ventes en Informatique
- Les meilleures ventes en Construction
- Les meilleures ventes en Entreprise & Droit
- Les meilleures ventes en Sciences
- Les meilleures ventes en Littérature
- Les meilleures ventes en Arts & Loisirs
- Les meilleures ventes en Vie pratique
- Les meilleures ventes en Voyage et Tourisme
- Les meilleures ventes en BD et Jeunesse