In this chapter
A look at what the BBC micro:bit is and how it came about A tour of the BBC micro:bit and an explanation of its major components THE BBC MICRO:BIT is an incredible device, capable of educating and entertaining in equal measure. It can form the heart of a complex robotic or home automation system, or it can simply show a smiley face when you press a button. It can help you come to grips with programming, learn about how electronics work, and even communicate wirelessly with more BBC micro:bits or other devices such as a smartphone or tablet.
You can write programs for the BBC micro:bit in a variety of programming languages, or you can use programs others have written. You can use the BBC micro:bit in the classroom, the club, the playground, or at home. You can play games, solve problems, and invent new devices, all with your BBC micro:bit.
Before all this, though, you’ll need to meet the BBC micro:bit.
A Tour of the Board
The BBC micro:bit is what is technically known as a microcontroller development board. That is, it’s a printed circuit board (PCB) which contains a microcontroller on which you can run your own programs and connect your own hardware.
The first microcontroller development boards were expensive and complicated to use. In the decades since their first introduction, they have become steadily cheaper and more accessible, until the BBC micro:bit became possible: a minimal-cost, highly-functional board designed to help teach programming, or ‘coding’, to anyone regardless of experience.
Your programming journey begins simply: learning about the BBC micro:bit itself.
WARNING
The BBC micro:bit is designed to be robust, but it’s still a complex electronic device. It’s designed as a bare circuit board so that you can see what all its components are and what they do, but this does mean you need to take a little more care with handling it than if it were in an enclosure. Always make sure to handle it by its edges to avoid damage through electrostatic discharge. For more information on preventing electrostatic discharge damage, see Chapter 2, ‘Getting Started with the BBC micro:bit’.
The BBC micro:bit itself is a small printed circuit board with a range of components fitted. It has two sides: the front side of the BBC micro:bit includes the display and buttons, while the back side has components like the micro-USB connector and radio. Figure 1-1 shows the front side of the BBC micro:bit, and Figure 1-2 shows the back.
The BBC micro:bit includes a layer of print known as a silkscreen layer, which labels some of the more important components. The buttons on the front side are labelled A and B so you know which is which, while the back side picks out key components like the processor and the accelerometer. These components, and others, are described in more detail in the next section.
Breaking It Down
Like any complex device, the BBC micro:bit is made up of numerous relatively simple parts. From the more obvious, like the display which dominates the front of the board, to the more subtle, like the radio which allows two or more BBC micro:bits to communicate with each other or connect to a smartphone or tablet, each component works with the others to give the BBC micro:bit its impressive flexibility.
If you’re impatient to get started with your BBC micro:bit, you can skip ahead to Chapter 2. Reading the rest of this chapter, though, will give you a good understanding of just what the BBC micro:bit can do, putting you in good stead for not only learning how it works but coming up with practical projects of your own as your skills progress.
Display
The most obvious feature of the BBC micro:bit is its display, which sits in the centre of the board’s front side (see Figure 1-3). This is the BBC micro:bit’s primary output device, a means for a program running on the BBC micro:bit to communicate with the outside world—whether that’s reading off the position of one of the BBC micro:bit’s sensors or simply displaying a smiling face.
The BBC micro:bit’s display serves the same purpose as the monitor on a desktop computer but is of a considerably lower resolution. Where a desktop monitor may be made up of 1,920 columns of 1,080 picture elements or pixels, the BBC micro:bit has just five columns of five picture elements for a total of 25 pixels.
Although 25 pixels may not sound like much, it’s more than enough to view useful information such as a bar graph or the elements of a simple game or to scroll messages of almost any length. You’ll learn more about using the display for these tasks and more later in the book.
From a technical perspective, the BBC micro:bit’s display is made up of a 5 × 5 light emitting diode (LED) matrix. Each LED in the matrix makes up one pixel and can display a single colour in varying brightnesses. By altering the brightness and rapidly changing the image being shown, the BBC micro:bit’s display can show animation as well as still images.
Buttons
Next to the display, the buttons are the BBC micro:bit’s second most obvious feature. The two main buttons, Button A and Button B, are positioned either side of the display at the front of the board and are labelled with their letter to avoid any confusion (see Figure 1-4). These two buttons form the BBC micro:bit’s primary input devices. Where the display allows information to be output from a program running on the BBC micro:bit, the buttons allow you to send simple inputs into the program to change the image being displayed, for example, or control a character in a game.
These buttons are technically known as a momentary switch. These are different to the switches you might use to turn on a light, which are known as latching switches or toggle switches. A momentary switch stays ‘on’ only as long as you continue to push it down, while a latching switch goes from ‘off’ to ‘on’ and stays there until you push it again.
Although the buttons are permanently connected to the BBC micro:bit, they won’t do anything unless the program running on the BBC micro:bit is listening for a button input. Depending on what you’re using the BBC micro:bit for, you may want to use only one or even neither of the two buttons; alternatively, you may find you need more buttons, in which case the input-output pins will help you expand the BBC micro:bit.
In addition to Button A and Button B, there’s a third button on the back of the BBC micro:bit: the Reset button. Like the Reset button of a desktop computer, the BBC micro:bit’s Reset button acts like cutting the...