Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
BBC Micro:bit in Practice
BBC Micro:bit in Practice

BBC Micro:bit in Practice: A hands-on guide to building creative real-life projects with MicroPython and the BBC Micro:bit

Profile Icon Ashwin Pajankar Profile Icon Abhishek Sharma Profile Icon Sandeep Saini
By Ashwin Pajankar , Abhishek Sharma , Sandeep Saini
$22.99 $33.99
Book Dec 2022 292 pages 1st Edition
eBook
$22.99 $33.99
Print
$41.99
Subscription
Free Trial
Renews at $19.99p/m
Profile Icon Ashwin Pajankar Profile Icon Abhishek Sharma Profile Icon Sandeep Saini
By Ashwin Pajankar , Abhishek Sharma , Sandeep Saini
$22.99 $33.99
Book Dec 2022 292 pages 1st Edition
eBook
$22.99 $33.99
Print
$41.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$22.99 $33.99
Print
$41.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

BBC Micro:bit in Practice

Introduction to the BBC Micro:bit

I certainly hope that you have read the preface and the table of contents, which provide a fair idea about our journey into the amazing world of the BBC Micro:bit (also written as Micro:bit or Micro Bit). This introductory chapter will warm you up for the upcoming exciting journey into the vast world of the Micro:bit. The road ahead is full of interesting concepts and projects. It is always a good idea to prepare well for the journey ahead, and this chapter will accomplish that.

We will explore the following topics in this chapter:

  • The history of the Micro:bit
  • The specifications of Micro:bit V1 and Micro:bit V2
  • Powering up the Micro:bit
  • Breakout boards
  • Fritzing to create circuit diagrams

Let’s get started!

Technical requirements

We will need the following hardware for this chapter:

  • BBC Micro:bit V1 or V2
  • A computer with Windows, macOS, or Linux
  • A BBC Micro:bit edge connector
  • A Micro-USB to USB cable
  • An internet connection
  • A mobile power bank
  • Kitronik Mi:power

The history of the Micro:bit

It is important to know the history of the BBC Micro:bit. The British Broadcasting Corporation (BBC) is the United Kingdom’s public broadcaster. It is also the world’s oldest and biggest broadcaster. BBC has always been pioneering in creating programs for outreach in science and technology to improve the public understanding of science. Its programs include various documentaries and television series.

One such interesting television series was The Computer Programme. It was broadcast on BBC Two and used a home computer, the BBC Micro, conceptualized by the BBC and developed by Acorn Computers. The TV series was a part of the BBC Computer Literacy Project. The BBC Micro had six different models, which were all based on the famous MOS Technology 6502 8-bit microprocessor. It is a simplified and faster version of the Motorola 6800 microprocessor. The 6502 is a very popular microprocessor, and variants of it were used in popular video game consoles and computers such as Atari 2600, Apple II, Nintendo Entertainment System (popularly known as NES or Famicom), Commodore 64, and, of course, the BBC Micro. The BBC Micro was very successful, and it made a great impact in the computer education sector, leaving a great legacy behind.

In 2012, with the release of Raspberry Pi, a new era was ushered into the world of computing and education. Through the Computer Literacy Project, the BBC sought to build upon the legacy of the BBC Micro after the great success of Raspberry Pi. It onboarded many partners from industry, such as Microsoft, and academia, such as Lancaster University. The first version (now referred to as the Micro:bit V1) was launched in July 2015 and was available for general sale in March 2016. The BBC also gave hundreds of thousands of Micro:bits to school children in the UK as a part of science education outreach. After the Micro:bit successfully launched, the BBC formed a not-for-profit organization known as the Microbit Foundation.

Note

For more details, you can visit the home page of the Microbit Foundation at https://microbit.org/.

In October 2020, the Microbit Foundation released the second version of the Micro:bit. V2 has got better specifications than V1 at the same price. We will explore the specifications of V1 and V2 side by side in the following section.

The specifications of Micro:bit V1 and Micro:bit V2

The following table compares the features of the BBC Micro:bit V1 and V2 side by side (source: https://microbit.org/):

BBC Micro:bit

V1

V2

Processor

Nordic nRF51822

Nordic nRF52833

Flash memory

256 KB

512 KB

RAM

16 KB

128 KB

Speed

16 MHz

64 MHz

Bluetooth

Bluetooth 4.0

Bluetooth 5.1 with Bluetooth Low Energy (BLE)

Radio communication

2.4 GHz radio (80 channels)

2.4 GHz radio (80 channels)

Buttons

Two programmable (A and B) and one system (reset)

Two programmable (A and B) and one system (power/reset)

On/off switch

None

Press and hold the rear power button

Touchpad

None

Touch-sensitive logo

Microphone

None

Onboard Knowles SPU0410LR5H-QB-7 MEMS microphone (with LED indicator)

Display

5x5 programmable LED matrix (25 LEDs in total)

5x5 programmable LED matrix (25 LEDs in total)

Speaker

None

Onboard JIANGSU HUANENG MLT-8530 (up to 80 dB)

Motion sensor and compass

LSM303AGR

LSM303AGR

Temperature sensor

On-board temperature sensor

On-core NRF52

Edge connector

25 pins

25 pins

Table 1.1 – Comparison of the features of BBC Micro:bit V1 and V2

The processors used in both versions are a special type of processor known as a System on Chip (also abbreviated as SoC or SOC). An SoC is an Integrated Circuit (IC) that has all or most components of a complete working computer system. A typical SoC has a processor, flash memory, and RAM. Both versions employ Advanced RISC Machines (ARM) processors. The ARM uses Reduced Instruction Set Computer (RISC) instruction architecture. The V1 uses Nordic nRF51822 SoC (https://www.nordicsemi.com/Products/nRF51822), and the V2 uses Nordic nRF52833 (https://www.nordicsemi.com/products/nrf52833). The Random Access Memory (RAM) is used to execute the programs. The flash memory is used to store the programs, and it is reprogrammable.

The following diagram shows the front faces of V2 and V1 side by side:

Figure 1.1 – Hardware features on the fronts of V2 and V1 (courtesy: ©Micro:bit Educational Foundation/microbit.org)

Figure 1.1 – Hardware features on the fronts of V2 and V1 (courtesy: ©Micro:bit Educational Foundation/microbit.org)

The following diagram shows the rear of the V2 and V1 side by side:

Figure 1.2 – The hardware features on the rears of V2 and V1 (courtesy: ©Micro:bit Educational Foundation/microbit.org)

Figure 1.2 – The hardware features on the rears of V2 and V1 (courtesy: ©Micro:bit Educational Foundation/microbit.org)

Another important aspect of the Micro:bit boards of both versions is that they come with edge connectors to interface with external hardware components. The following diagram explains the slight difference between the edge connectors of V2 and V1 side by side:

Figure 1.3 – The edge connectors of V2 and V1 (courtesy: https://tech.microbit.org/hardware/edgeconnector/)

Figure 1.3 – The edge connectors of V2 and V1 (courtesy: https://tech.microbit.org/hardware/edgeconnector/)

You can read online about the edge connectors in detail at https://tech.microbit.org/hardware/edgeconnector/ and https://microbit.pinout.xyz/.

I understand that you may feel a bit overwhelmed with all this technical information at this stage. Without enough context about the utility of this technical information, it is natural to feel that way. However, in the upcoming chapters, we will learn about and demonstrate all these features in detail.

Now that we have a fair understanding of the history and specifications of the Micro:bit, let’s learn various methods to power it up.

Powering up the Micro:bit

There are a few ways we can power up the Micro:bit. Let’s see them all one by one. The following diagram clearly shows the micro-USB port and the battery socket. We can power up the BBC Micro:bit using these:

Figure 1.4 – The battery socket and micro-USB port (courtesy: https://commons.wikimedia.org/wiki/File:BBC_micro_bit_%2826238853955%29.png)

Figure 1.4 – The battery socket and micro-USB port (courtesy: https://commons.wikimedia.org/wiki/File:BBC_micro_bit_%2826238853955%29.png)

We can use a micro-USB male to USB male cable to power the Micro:bit. The following is the micro-USB end of such a cable:

Figure 1.5 – A micro-USB male connector (courtesy: https://commons.wikimedia.org/wiki/File:MicroB_USB_Plug.jpg)

Figure 1.5 – A micro-USB male connector (courtesy: https://commons.wikimedia.org/wiki/File:MicroB_USB_Plug.jpg)

Insert this end into the Micro:bit, as shown in the following photo:

Figure 1.6 – A micro-USB male connector (courtesy: https://commons.wikimedia.org/wiki/File:Bbc-microbit-2021.jpg)

Figure 1.6 – A micro-USB male connector (courtesy: https://commons.wikimedia.org/wiki/File:Bbc-microbit-2021.jpg)

Insert the other end into a computer or a power bank. The following is an image of a mobile/portable power bank:

Figure 1.7 – A power bank with a micro USB cable attached (courtesy: https://commons.wikimedia.org/wiki/File:Portable_power_bank.jpg)

Figure 1.7 – A power bank with a micro USB cable attached (courtesy: https://commons.wikimedia.org/wiki/File:Portable_power_bank.jpg)

We can also use a pair of AAA batteries with a special connector, as shown in the following photo:

Figure 1.8 – A battery connector (courtesy: https://commons.wikimedia.org/wiki/File:Cavo_Microbit.jpg)

Figure 1.8 – A battery connector (courtesy: https://commons.wikimedia.org/wiki/File:Cavo_Microbit.jpg)

You can procure such a connector online at various marketplaces. One such page is https://www.sparkfun.com/products/15101. There are many other websites too that sell these connectors. You can also check your local makers’ electronic supply shops for this.

The following photo shows the Micro:bit powered up with this connector and a pair of AAA batteries:

Figure 1.9 – A battery connector connected to the Micro:bit

Figure 1.9 – A battery connector connected to the Micro:bit

We can also power the Micro:bit with a CR2032-type power cell, as shown in the following figure:

Figure 1.10 – CR2032 power cells (courtesy: https://commons.wikimedia.org/wiki/File:Cr2032-7mmgrid.jpg)

Figure 1.10 – CR2032 power cells (courtesy: https://commons.wikimedia.org/wiki/File:Cr2032-7mmgrid.jpg)

We can use various special connectors to connect it with the Micro:bit. One special connector board is MI – the power board by Kitronik (https://kitronik.co.uk/products/5610-mipower-board-for-the-bbc-microbit). Figure 1.11 shows a photo of the board, the nuts, and the CR2032 battery that comes with it:

Figure 1.11 – The MI:power board and contents of the package

Figure 1.11 – The MI:power board and contents of the package

Figure 1.12 is a photo of the rear of the Micro:bit attached to the MI:power board:

Figure 1.12 – The Micro:bit assembled with the MI:power board

Figure 1.12 – The Micro:bit assembled with the MI:power board

We can see that there is a dedicated ON/OFF switch. Attaching the board to the Micro:bit is very easy, and we can check the instructions for assembly at https://kitronik.co.uk/products/5610-mipower-board-for-the-bbc-microbit.

Both versions of the Micro:bit come with booklets, as shown in the following image:

Figure 1.13 – Micro:bit instruction booklets

Figure 1.13 – Micro:bit instruction booklets

It is recommended to go through them for a better understanding.

The out-of-box experience

When we unbox the Micro:bit and power it up for the very first time, it runs a factory default program known as the out-of-box experience. It is lots of fun to learn about the features of the Micro:bit using this program. Unbox and power your Micro:bit to run this program. Enjoy exploring the features of the Micro:bit.

Now that we have explored various ways to power the Micro:bit, we will explore special hardware components known as breakout boards.

Breakout boards

The General Purpose Input Output (GPIO) pins of the Micro:bit are extremely narrowly printed on the edge connector. It is difficult to use them directly, and soldering can ruin the board. So, many organizations have developed special products that make the GPIO pins of the Micro:bit easily accessible. These products are known by various names, such as breakout boards, GPIO expanders, I/O extensions, and edge connectors. The following are the URLs of the web pages for such products:

I urge you all to procure one of these or any other edge connector of your choice, as we will need these for the demonstrations in this book.

I, too, own a couple of them, as shown in the following photos:

Figure 1.14 – A couple of edge connectors I own

Figure 1.14 – A couple of edge connectors I own

Here, we have Micro:bit V1 and V2 inserted into the edge connectors:

Figure 1.15 – Micro:bits with the edge connectors

Figure 1.15 – Micro:bits with the edge connectors

In the following section, we will get acquainted with a software program, Fritzing, that will help us visualize circuits.

Fritzing to create circuit diagrams

I am using software known as Fritzing (https://fritzing.org/) to create the circuits depicted in this book. It is not mandatory software for the demonstrations, as all the circuit diagrams are already printed in the book. However, if you wish to create your own circuit diagrams with Fritzing, you must procure them separately for 8 euros from https://fritzing.org/download/. I have included the Fritzing diagram files (with the .fzz extension) in the code bundle of the book. You can open them using the Fritzing software and modify them. It is very convenient software, and many hardware hackers (including us, the book’s authors) use it to design and visualize their projects.

Fritzing has a library of many routinely used electronic and electrical components that include various boards. Also, users can create their own custom components such as boards and add them to their Fritzing setup. Many of them make such components available to other users for free. These components are stored in files with the .fzpz extension. You can find the component files for the BBC Micro:bit and many edge connectors at the following URLs:

Download the part files. Open the Fritzing software. In the Parts panel (the top-right panel), right-click on an empty gray space to show a dropdown, as shown in Figure 1.16:

Figure 1.16 – Importing a part to Fritzing

Figure 1.16 – Importing a part to Fritzing

The first option is Import…. Click on that, and it opens a standard file selection window of the OS. Select the downloaded component files for the Micro:bit and edge connectors (those with the .fzpz extension) and import them. We can import only one component at a time. Once imported, all the components will be visible in the tab labeled MINE (refer to Figure 1.16). The following figure is a screenshot of those components added to a circuit diagram under development:

Figure 1.17 – Using the BBC micro:bit and edge connector parts in circuit diagrams

Figure 1.17 – Using the BBC micro:bit and edge connector parts in circuit diagrams

This is how Fritzing can be used to visualize the circuits we will build for the demonstrations throughout this book. You will find similar and more detailed circuit diagrams in the upcoming chapters of the book.

Summary

In this chapter, we learned a few fundamentals about the BBC Micro:bit. We had a brief tour of the hardware features that we will explore in the coming chapters. We also learned about the ways to power the board and edge connectors.

In the next chapter, we will focus on the software aspect of the Micro:bit and learn the basics of Python and MicroPython. We will start with installing various IDEs. We will also learn how to upgrade the firmware of the Micro:bit.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore hardware programming and leverage the power of the BBC Micro:bit and MicroPython
  • Build real-life creative projects step by step with each chapter increasing in complexity and interactivity
  • Learn the features of the Micro:bit and how to interface it with electronic components through circuits and code examples

Description

This book is a one-stop guide for learning BBC Micro:bit with MicroPython, exploring many hardware components and programming techniques to provide detailed insights into developing practical applications with the Micro:bit. It will also show you how hardware components can be manipulated using a combination of Micro:bit and MicroPython for developing practical projects. BBC Micro:bit in Practice will help you gain a holistic understanding of the BBC Micro:bit platform and MicroPython programming, guiding you through mini projects aimed at developing practical knowledge of circuit design and writing programs. You’ll learn how to write programs for working with built-in LEDs and buttons, interfacing external LEDs, buttons, motors, buzzers, and much more. You’ll also work with built-in radio, speakers, accelerometer, and a compass. You’ll dive into concepts related to the Micro:bit filesystem, interfacing external displays, and working with libraries in detail before exploring sewable circuits and wearable technology. After reading this Micro:bit book, you’ll understand how to apply principles in electronics and MicroPython to create interesting real-life projects from scratch.

What you will learn

  • Explore the essentials of the BBC Micro:bit, its hardware specifications, and versions
  • Program built-in and external LEDs and buttons
  • Program external LED-based displays, buzzers, and stepper motors
  • Use analog input and pulse width modulation to drive a servo motor
  • Detect gestures with internal sensors such as accelerometer, compass, and magnetometer
  • Work on projects with built-in features such as music, speech, radio, and filesystem
  • Explore the advanced features of the Micro:bit

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 9, 2022
Length 292 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781804610121
Category :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Dec 9, 2022
Length 292 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781804610121
Category :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together

Stars icon
Total $ 70.97 103.97 33.00 saved
Raspberry Pi Pico DIY Workshop
$28.99 $41.99
BBC Micro:bit in Practice
$22.99 $33.99
Raspberry Pi and MQTT Essentials
$18.99 $27.99
=
Book stack Total $ 70.97 103.97 33.00 saved Stars icon

Table of Contents

22 Chapters
Preface Chevron down icon Chevron up icon
1. Part 1: Getting Started with the BBC Micro:bit Chevron down icon Chevron up icon
2. Chapter 1: Introduction to the BBC Micro:bit Chevron down icon Chevron up icon
3. Chapter 2: Setting Up the Micro:bit and Using Code Editors Chevron down icon Chevron up icon
4. Chapter 3: Python Programming Essentials Chevron down icon Chevron up icon
5. Chapter 4: Advanced Python Chevron down icon Chevron up icon
6. Part 2: Programming Hardware with MicroPython Chevron down icon Chevron up icon
7. Chapter 5: Built-in LED Matrix Display and Push Buttons Chevron down icon Chevron up icon
8. Chapter 6: Interfacing External LEDs Chevron down icon Chevron up icon
9. Chapter 7: Programming External Push Buttons, Buzzers, and Stepper Motors Chevron down icon Chevron up icon
10. Part 3: Filesystems and Programming Analog I/O Chevron down icon Chevron up icon
11. Chapter 8: Exploring the Filesystem Chevron down icon Chevron up icon
12. Chapter 9: Working with Analog Input and PWM Chevron down icon Chevron up icon
13. Part 4: Advanced Hardware Interfacing and Applications Chevron down icon Chevron up icon
14. Chapter 10: Working with Acceleration and Direction Chevron down icon Chevron up icon
15. Chapter 11: Working with NeoPixels and a MAX7219 Display Chevron down icon Chevron up icon
16. Chapter 12: Producing Music and Speech Chevron down icon Chevron up icon
17. Chapter 13: Networking and Radio Chevron down icon Chevron up icon
18. Chapter 14: Advanced Features of the Micro:bit Chevron down icon Chevron up icon
19. Chapter 15: Wearable Computing and More Programming Environments Chevron down icon Chevron up icon
20. Index Chevron down icon Chevron up icon
21. Other Books You May Enjoy Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.