Index

Please note that index links point to page beginnings from the print edition. Locations are approximate in e-readers, and you may need to page down one or more times after clicking a link to get to the indexed material.

Page numbers in italics refer to figures.

abs function, 99

absolute value, 99

accelerometer module, 4

getting raw data, 96–99

Adventures in Minecraft (Whale), 136

alarm project, 121–123

alligator clips, 109–110, 120–121

amplifier modules, 121, 122

analog inputs, 109, 115–119

analog outputs, 109, 113–115

animation, 89–90

racing game, 91–92

See also images

Arduino Uno, vs. micro:bit, 5–6

ARMmbed, 19

attributes, 76

audio, 120

alarm project, 121–123

alligator clip to audio socket, 120–121

amplifier modules, 121, 122

music, 123–124

speech, 124

batteries, 45–46

battery life, 107–108

battery tester, 115–117

3 V battery pack, 107

BBC. See British Broadcasting Corporation (BBC)

bitio, 136

installing, 137, 138

using from the console, 137–139

Bitio Project, 136

blocking, 87

Bluetooth, 131

breakout boards and kits, 128–129

British Broadcasting Corporation (BBC), 3–4

built-in modules, 73–75

classes, 75–76

defining, 81

inheritance, 76–78

making a module that uses a class, 80–83

coding, 7

self-documenting code, 57

See also programming

comments, 57

comparison operators, 150

compass, 4

calibrating, 99–100

See also magnetometer module

compiling, 8

components, suppliers and manufacturers, 158–160

concatenation, 29

See also strings

conditions, 34–35

connecting to a computer, 1–3

constants, 27

crocodile clips, 109–110

debugging, 66–67

Dictionaries, 45, 51

accessing elements of a Dictionary, 53–54

adding items to a Dictionary, 54

functions, 154

gesture-detector project, 51–53

digital inputs, 109, 115, 116

digital outputs, 108, 110–113

downloading example programs, 23–24

DRY, 58–59

edge connector

breakout boards and kits, 128–129

disabling hardware, 129

overview, 126–127

pinout, 127–128, 157

See also touch pins

else, 34–35

embedded software, 55

escape characters, 151

exception handling, 68–69

expansion boards, suppliers and manufacturers, 160

file system, 69–71

finite state machines (FSMs), 59

See also state machine design

flashing, 8, 32

floats, 25

for loops, 33–34

freefall, 96

functions, 29

body, 41

calling, 40, 41

definition, 40, 41

Dictionary, 154

List, 153

number, 151

overview, 39

parameters, 40–42, 44

returning a value, 43–44

string, 152

George, Damien, 8

gesture-detector project, 51–53

gestures, 96

get_presses( ), 95

Github repository, 23–24

global variables, 42–43, 47, 101

Google Chrome, installing micro:bit programs, 13–14

GPIO pins, 108–119

hardware

disabling, 129

micro:bit edge connector pinout, 157

suppliers and manufacturers, 158–159

Hello message, 3

in JavaScript Blocks, 142–143

hex (hexadecimal), 8

I2C, 128

if, 34–35

images

animation, 89–90

racing game, 91–92

showing, 88–89

inheritance, 76–78

inputs, 7

instance variables, 82

instances, 75–76

integers, 25

integrated circuits (ICs), 112

inverse square law, 101–102

is_pressed( ), 95

JavaScript Blocks, 8, 141

displaying “Hello World!” message, 142–143

editor, 141–142

events, 144

magnetometer program, 147

variables and loops, 144–146

kits, suppliers and manufacturers, 159

LED display, 4

animation, 89–90

controlling individual LEDs, 85–86

neopixels, 124–126

racing game, 91–92

scrolling text, 87

showing an image, 88–89

showing text, 88

LEDs, suppliers and manufacturers, 159–160

libraries, 83

Linux

installing micro:bit programs, 14–16

installing Mu, 19

Lists, 45

accessing elements of a List, 48–49

adding to a List, 49

deleting from a List, 49–50

functions, 153

joining Lists together, 50

message board example, 45–48

strings as a list of characters, 50–51

local variables, 41

loops, 31–32

Mac

installing micro:bit programs, 11–13

installing Mu, 19

magnetometer module, 99–102

JavaScript Blocks program, 147

See also compass

manufacturers

basic components, 159–160

hardware, 158–159

kits, 159

modules and expansion boards, 160

message board example, 45–48

methods, 32, 76, 81–83

micro:bit, 1

connecting to a computer, 1–3

features, 4–5

front and back views, 2

history of, 3–4

vs. Raspberry Pi and Arduino Uno, 5–6

Microbit Educational Foundation, 4, 8

MicroPython, 7

comments, 57

comparison operators, 150

converting numbers to strings, 29

Dictionary functions, 154

else, 34–35

escape characters, 151

file system, 69–71

for loops, 33–34

if, 34–35

images, 88–89

language constructs, 149–150

List functions, 153

loops, 31–34

Mu, 9

number functions, 151

numbers, 25–26

online editor, 9, 10–17

overview, 8

programs, 30–31

string functions, 151–152

strings, 28–29

type conversions, 155

variables, 27–28

while loops, 31–32, 35–36

See also Python

MicroPython online editor, 9

installing micro:bit programs using a Mac, 13–14

installing micro:bit programs using Linux, 14–16

installing micro:bit programs using Windows, 11–13

overview, 10

saving and loading programs, 17

Microsoft Edge, installing micro:bit programs, 11–13

Minecraft, remote controlling with the micro:bit, 136

modules

built-in, 73–74

importing, 74–75

libraries, 83

making a module that uses a class, 80–83

making simple modules, 78–80

suppliers and manufacturers, 160

MonkMakes Basic Components Kit, 160

MonkMakes relay board, 112, 113, 115

MonkMakes sensor board, 118

MonkMakes Speaker, 121, 122

motor driver boards, suppliers and manufacturers, 160

Mu editor, 9

changing code, 31

downloading example programs to use in, 24

installing on a Mac, 19

installing on Linux, 19

installing on Windows, 18–19

overview, 17

using Mu, 19–21

music, 123–124

“neo” neodymium magnet, 100

See also magnetometer module

neopixels, 124–126

number functions, 151

numbers

converting to strings, 29

working with, 25–26

operating voltage, 108

outputs, 7

parameters, 33, 40–42

optional parameters with default values, 44

See also functions

photoresistors, suppliers and manufacturers, 159–160

pins, 109

See also GPIO pins

pluralize function, 78–80

powering a micro:bit

battery life, 107–108

battery pack, 45–46

operating voltage, 108

3 V battery pack, 107

USB power lead, 45–46

USB power pack, 105–106

powering out, 119

private methods, 82

programming, 7–8

programs, 30–31

writing your own, 55–59

Proto-PIC amp:bit, 121, 122

public methods, 82

pulse width modulation (PWM), 114–115

push buttons A and B, 4, 95

Python

comments, 57

Dictionaries, 45

exception handling, 68–69

file system, 69–71

floats, 25

formatting, 67

integers, 25

Lists, 45–48

running on your computer, 137

See also bitio; MicroPython

racing game, 91–92

radio communications, 131

adjusting length of message, 135

basic micro:bit-to-micro:bit communication, 131–132

computer-to-micro:bit communication, 135

increasing the range, 134

sending messages to specific micro:bits, 132–134

radio module, 4

range errors, 47

Raspberry Pi

installing micro:bit programs, 14–16

installing Mu, 19

vs. micro:bit, 5–6

Read Eval Print Loop. See REPL

refactoring, 57–59

relay boards, suppliers and manufacturers, 160

remote controlling the micro:bit, 136–139

REPL, 17, 21–23

accessing elements of a Dictionary, 53–54

accessing elements of a List, 48–49

computer-to-micro:bit communication, 135

controlling individual LEDs, 85–86

debugging, 66–67

for loops, 33

getting raw accelerometer data, 96–99

running programs, 30–31

scrolling text, 87

showing text, 88

spike solutions, 56

working with numbers, 25–26

working with strings, 28–29

working with variables, 27–28

Reset button, 3

resistors, suppliers and manufacturers, 159–160

return values, 43–44

scroll method, 39

scrolling text, 87

self-documenting code, 57

sensors

accelerometer, 4, 96–99

light-sensing circuits, 119

magnetometer, 99–102, 147

MonkMakes sensor board, 118

suppliers and manufacturers, 160

temperature, 102

touch, 102–104

serial programming interface (SPI), 127

shake, 96

shock, 96

showing an image, 88–89

showing text, 88

sleeping, 32

solderless breadboards, 128–129

solid-state relays, 112

sound output, 120

alarm project, 121–123

alligator clip to audio socket, 120–121

amplifier modules, 121, 122

music, 123–124

speech, 124

speakers, suppliers and manufacturers, 160

speech, 124

spike solutions, 56

state machine design, 59–61

adding code for the ALARM state, 65

adding code to the RUN state, 63–65

adding code to the SET state, 63

state machine framework for timer project, 61–62

switching between states, 62

string functions, 151–152

strings, 28–29

converting numbers to, 29

format strings, 67

as a list of characters, 50–51

substrings, 51

suppliers

basic components, 159–160

hardware, 158–159

kits, 159

modules and expansion boards, 160

temperature sensor, 102

text

scrolling, 87

showing, 88

timer project, 36–37

adding alarm, 121–123

state machine design, 59–65

touch pins, 4, 102–104

See also edge connector

type conversions, 155

underscore, 39

uploading, 8, 32

USB power lead, 45–46

USB power pack, 105–106

USB to micro-USB connector, 1–3

variables, 27–28, 47

global variables, 42–43, 101

in JavaScript Blocks, 144–146

local variables, 41

versioning, 56

was_pressed( ), 95

Whale, David, 136

while loops, 31–32, 35–36

Windows

installing micro:bit programs, 11–13

installing Mu, 18–19

wireless communications. See radio communications

writing software, 55–59