New Scientist - USA (2019-06-08)

(Antfer) #1
8 June 2019 | New Scientist | 51

New stuff you need
BBC micro:bit starter kit


For next week
If you have collected the
parts for previous projects,
you should have
everything you need


Next in
the series
1 Introduction
2 Electric candle
3 Toast notifier
4 Desktop traffic light
5 Propeller car
6 Magic 8 Ball
7 Theremin
Make a musical
instrument you don’t
have to touch
8 Sound-sensitive
disco ball
9 Rubbish sweeper
10 Biscuit bot


UNTIL now, everything we have
made has been stupid. This week,
we are giving a circuit a brain.
To do this, we will use a BBC
micro:bit, a tiny entry-level
microcontroller. You write
instructions on a computer,
then plug in the micro:bit and
download them. When you hook
the micro:bit up to your circuit, it
takes care of what happens when.
Go to the micro:bit website,
click “Let’s code” and find the
MakeCode editor’s “New project”
section. On one side, there is
a menu of blocks, all of which
are programming instructions,
arranged in categories. Under
“Input”, find the one that says
“on shake” and drag it into
the workspace. This will tell the
micro:bit to respond when you
shake it. Now, we can use other
blocks to control that response.
Under “Basic”, find “show
string”, then click, drag and drop
so that it snaps into the middle
of “on shake”. Download it to
your micro:bit and you will find
that this simple program will
make the words you write in this
block scroll across the micro:bit’s
LED screen when you shake it.
To expand on this, we can
make a kind of Magic 8 Ball.
On each shake, the micro:bit will
show a random message from a
list of possibilities. The first step
is to make a random number
generator. In the “Variables” list,
hit “Make a Variable” and type
“random number” into the box.
Grab an “on shake” as before,
but this time, slot in the “set
random number to 0” block from

your variables list. Onto the 0 at
the end of that block, slot “pick
random 0 to 10”, which you’ll
find in the “Math” section.
Next, we want the program to
do different things for different
numbers. Under “Logic”, find an
“if <true> then” block. Add that to
the bottom of the “on shake”, then
slot the logic comparison “0 = 0”
between if and then. Replace the
first 0 with the “random number”
variable from the list you made.
Add a “show string” block in the
space below the “if ” line, and
write a message there.
From now on, click the + sign
on your “if <true> then” block a
few times to add extra messages.

Use the same kind of blocks in each
section, but change the numbers –
so, if random number = 1, type a
different message. How many?
If your random number generator
goes from 0 to 10, you will need
a message for each outcome. If
you get stuck, the program is in
the online version of this story.
Make the messages as wise,
or rude, or positive as you like.
Maybe use it like a fortune cookie,
preprogramming sage advice to
receive at random.
There is plenty more you can
do with your micro:bit, like make
a pedometer or a timer. Engage
your imagination and show us
on social media. ❚

How to be a maker Week 6


Code me random


Want to program a computer, but don’t know how?
Hannah Joshua’s fun method has an uncertain outcome

Puzzles
Cryptic crossword, a
three dart problem
and a quiz p52

Feedback
Shaman shaming and
Martian misery: the
week in weird p53

Almost the last word
Hand drying and car
crashes: your queries
answered p54

Me and my telescope
Zoe Laughlin on
wondrous materials
and Dolly Parton p56

What does...
Liana Finck?
A cartoonist’s take
on the world p53

The back pages


DA

VID

ST

OC

K^ F

OR

NE

W^
SC

IEN

TIS

T

Hannah Joshua is a science
writer and maker based in
London. You can follow her
on Twitter @ hannahmakes


USB CONNECTOR FOR DOWNLOADING
INSTRUCTIONS

PINS TO CONNECT
EXTERNAL HARDWARE
(FOR LATER!)

LED LIGHTS TO
DISPLAY TEXT
AND IMAGES

Make online
Projects so far and a full list of kit required are at
newscientist.com/maker Email: [email protected]
Free download pdf