Sparkfun Electronics Inventor's Kit User manual

SparkFun Inventor's Kit for micro:bit
Experiment Guide
Introduction to the SparkFun Inventor's Kit for micro:bit
The SparkFun Inventor’s Kit for micro:bit Experiment Guide is your map for navigating the waters of
beginning embedded electronics, robotics and citizen science using the micro:bit. This guide
contains all the information you will need to explore the 12 circuits of the SparkFun Inventors Kit for
micro:bit. At the center of this guide is one core philosophy — that anyone can (and should)
experiment with cutting-edge electronics in a fun and playful way without breaking the bank.
When you’re done with this guide, you’ll have the know-how to start creating your own projects and
experiments. From building robots and game controllers to data logging, the world will be your
oyster. Now enough talking — let’s start tinkering!
SparkFun Inventor's Kit for micro:bit
KIT-14542

SparkFun Inventor's Kit for micro:bit Lab Pack
LAB-14301
Included Materials
The SparkFun Inventor’s Kit (SIK) for micro:bit includes the following:
micro:bit — The brains of the outfit with a bunch of onboard components.
micro:bit Breakout (with Headers) — Allows you to connect the micro:bit to the
breadboard.
Breadboard — Excellent for making circuits and connections off the micro:bit. We included a
full-sized breadboard to give you plenty of room.
Small Servo — Here is a simple, low-cost, high-quality servo for all your mechatronic needs.
Piezo Buzzer — BUZZZZ! Used to make different frequencies of sound.
USB micro-B Cable — This 6-foot cable provides you with a USB-A connector at the host
end and standard B connector at the device end.
Male-to-Male Jumper Wires — These are high-quality wires that allow you to make
connections with components on the breadboard.
TMP36 Temperature Sensor - A sensor for detecting temperature changes.
Photocell — A sensor to detect ambient light. Perfect for detecting when a drawer is opened
or when nighttime approaches.
Tri-Color LED — Because everyone loves a blinky.

Red, Blue, Yellow, and Green LEDs — Light-Emitting Diodes make great general
indicators.
Momentary Pushbutton Switch — Go crazy with buttons.
10kΩTrimpot — Also known as a variable resistor, this is a device commonly used to
control volume and contrast, and makes a great general user control input.
100ΩResistors — Great current-limiting resistors for LEDs, and strong pull-up resistors.
10kΩResistors — These make excellent pull-ups, pull-downs and current limiters.
2x AA Battery Pack — A AA battery pack with the JST connector that fits the micro:bit
Alligator Clip with Pigtail — A great way to connect individual components on a
breadboard to the micro:bit ring connectors.
Throughout the tutorial, we will provide links to the parts used for each circuit. Below is the wishlist
for the parts used in the kit. You may not need everything though depending on what you have. Add
it to your cart, read through the guide, and adjust the cart as necessary.
SPARKFUN INVENTOR'S KIT FOR MICRO:BIT WISHLIST
Suggested Reading
Before continuing with this guide, we recommend you be somewhat familiar with the concepts in the
following tutorials:
What is a Circuit?
Every electrical project starts with a circuit. Don't know what a circuit is? We're here to help.
Voltage, Current, Resistance, and Ohm's Law
Learn about Ohm's Law, one of the most fundamental equations in all electrical engineering.
How to Use a Breadboard
Welcome to the wonderful world of breadboards. Here we will learn what a breadboard is and how to
use one to build your very first circuit.
Open Source!
All of our experiments and guides are licensed under the Creative Commons Attribution Share-Alike
4.0 Unported License. Feel free to remix and reuse our work. But please, share the love and give us
attribution for our hard work!

To view a copy of this license visit this link, or write: Creative Commons, 171 Second Street, Suite
300, San Francisco, CA 94105, USA.
What is the micro:bit?
Introduction
The micro:bit is a pocket-sized computer that lets you get creative with digital technology. You can
code, customize and control your micro:bit from anywhere! You can use your micro:bit for all sorts of
unique creations, from robots to musical instruments and more.
micro:bit Board
DEV-14208
3
The micro:bit is the most recent project by the British Broadcasting Corp. (BBC) in an effort to bring
computer science education and STEM topics to every student in the United Kingdom. It is an open
development board that works in sync with onboard hardware components to get you started down
the path of programming hardware.
At half the size of a credit card, each board is equipped with a surprising amount of hardware,
including 25 red LED lights that can flash messages. There are two programmable buttons that can
be used to control games or pause and skip songs on a playlist. The micro:bit can even detect
motion and tell you which direction you’re heading. It can also use Bluetooth Low Energy (BLE) to
interact with other devices and the internet.
The micro:bit features an embedded compass and accelerometer, and mobile and web-based
programming capabilities. It is compatible with a number of online code editors across a number of
different languages. This guide will focus on MakeCode, a block- or JavaScript-based environment
developed by Microsoft.

What is on the Board?
The micro:bit has a lot to offer when it comes to onboard inputs and outputs. In fact, there are so
many things packed onto this little board that you would be hard-pressed to really need anything
else if your goal is to explore the basics of programming and hardware.
Front
On the front of the board there are a number of components that are pretty visible right off the bat!
1. LED Array — The micro:bit has a 5x5 LED array that you can use as a tiny screen to draw
on and display words, numbers and other information.
2. A/B Buttons — Two buttons in all of their clicky glory: A is on the left, B is on the right, and
both are prime for controlling a game of your design.
3. Edge “Pins” — The gold tabs at the bottom of the board are for hooking up external
components. The tabs with larger holes can be easily used with alligator clips to prototype
things quickly!
4. Light Sensor — A bit of a hidden gem. The LED array doubles as a light sensor!
Back
The back is where a lot of the magic happens. Check it out…
1. Microcontroller — The brains of the outfit. The micro:bit is powered by a 16MHz ARM
Cortex-M0 microcontroller with 256KB Flash and 16KB RAM.

2. Accelerometer/Compass — The micro:bit has an onboard accelerometer that measures
gravitational force, as well as a compass that can detect its orientation using Earth’s
magnetic field.
3. Bluetooth/Radio — Communication is huge with the micro:bit. You can communicate with
your phone or tablet using BLE or between two or more micro:bits using the standard “radio.”
4. Temperature Sensor — No, the drawing is not numbered incorrectly! The microcontroller
doubles as a temperature sensor!
5. USB Port — Used to upload code to your micro:bit or power from your computer or laptop.
6. Reset Button — A button to reset your micro:bit and start your code over from the
beginning.
7. JST Battery Connector — A connector to hook up an external battery pack to your
micro:bit.
Hooking It Up
The micro:bit uses a microUSB cable to hook up to your computer or Chromebook. It is as simple as
plugging the cable into your micro:bit and the other end into an open USB port.
Once you plug your board in, you should see the small yellow LED on the back of your micro:bit light
up and possibly blink a few times. Then whatever existing program that was put on the micro:bit will
start running. If this is your first time plugging your micro:bit in, go ahead and play around with it a bit
— push buttons, shake it, and you will get a bit of an Easter egg.
Once your micro:bit boots up, check out your Finder if you are on a Mac, or your My Computer
Drives if you are on a PC. The micro:bit should show up as an external storage device with two files
stored in it.

If you are on a Chromebook, when you plug your micro:bit in you will be greeted with a dialog box to
open the drive. Feel free to do so to make sure it works!
Introduction to Microsoft MakeCode
What is MakeCode?
MakeCode is an open programming environment built by Microsoft for the micro:bit, as well as other
boards. You can navigate to MakeCode for the micro:bit by clicking on the button below.
LAUNCH MAKECODE!
Once you have launched MakeCode, you will be greeted by its basic layout with a simulator on the
left and a block-based environment on the right, as shown here.
Click on the image above for a larger view.

Let’s take a quick tour and check out what is available to us!
1. Projects — A cloud storage system connected to your computer with no account setup
required.
2. Share — Allows you to share your project code in a number of different ways with your
friends!
3. Blocks/JavaScript — Choose your own adventure by programming in blocks (default) or in
JavaScript.
4. Program Space — This is where the magic happens and where you build your
program…where you “make code.”
5. Zoom/Undo-Redo — Sometimes you need to undo things, or zoom out and look around;
these are the buttons for that.
6. Name & Save — Name your program and save it (download it) to your computer.
7. Download — Similar to Save, download your program as a .hex file and drag it into your
micro:bit.
8. Block Library — All of the options in terms of program building blocks, which are color-
coded by function.
9. Simulator Hide/Show — You can hide/show the simulator if you would like.
10. Simulator — You don’t need hardware! MakeCode has a real-time simulator! As you change
your program, you can see what it will do on this virtual micro:bit!
Phew! Now you have a choice: block- or text-based programming?
Blocks or Text
For this guide and the majority of the content that you will find on SparkFun for the micro:bit, we will
be using block-based programming examples.
[
But, if you so choose, there is a JavaScript option to use as well. The choice is yours, and the good
news is that you can switch back and forth from one to the other in the same program; one will
populate the other, which is really nice if you are new to programming!
Simulator
MakeCode includes a simulator for the micro:bit, meaning if you don’t have your micro:bit in hand
you can still write code for it. Or if you want to try out an idea before you upload it to your micro:bit,
you can do that too!

The simulator will update as you build your code, and if you want to run it from the beginning you
can click the stop and run buttons to start it over again!
Speaking of code, let’s write a quick program and get it onto your micro:bit!
Experiment 0: Hello, micro:bit!
Introduction
“Hello World” is the term we use to define that first program you write in a programming language or
on a new piece of hardware. Essentially it is a simple piece of code that gives you a quick win
(fingers crossed) and a first step in learning. It also gives you a chance to make sure everything is
up and running and A-OK.
For your first “Hello World” we are going to create a simple animation on the LED array that repeats
forever. If you just want the complete program, you can see it here. To see a step-by-step
explanation of how we built the program, continue reading!
Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming
environment and simulated circuit!
Building ‘Hello World’
A “Hello World” on the micro:bit is a little different than on a normal run-of-the-mill microcontroller.
The micro:bit has no single LED to blink on its own, as you would find on the Arduino or similar
boards. What the micro:bit does have is an LED array! So, the “Hello World” for the micro:bit is to
draw something using the LED array!
When you open MakeCode you are greeted with two blocks: the
OnStart
block and
the
forever
block. The
OnStart
block is all of your code that will execute at the very beginning of
your program and only run once. The
forever
block is code that will loop over and over
again…forever.

We are going to use the
forever
block for building this “Hello World.” We now need to start adding
blocks to
forever
.
First, click on the Basics category. These blocks are, well, the basic building blocks of a BuildCode
program. It will expand into a number of options. Click and drag the
showleds
block over and place it
inside of your
forever
block. Notice that the block is keyed to fit inside of the
forever
block, and if
you have the volume up on your computer you will hear a satisfying ‘click’ noise when you let go of
the block.
The
showleds
block has an array of squares that symbolize the LED array. If you click on a square,
it will turn red, which means that it is on. Draw a simple pixel art shape by turning different LEDs on
or off; you should be able to see the outcome in your simulator on the lefthand side of your window.

To turn this static image into an animation, we need another
showleds
block to place just under the
first block. You can then make a second drawing with this set of rectangles. In your simulator you will
see the images switching really, really fast. We need to slow this down!
To slow your animation down, you will use the
pause
block, which is under the basic block set.
The
pause
block is just what it says; it tells the micro:bit to pause and wait for a certain amount of
time. Place two
pause
blocks in the program as shown.
The reason we are using two and placing one at the end is that this program is a loop. Without the
block at the end, the image in your animation will change really, really fast.

We have built up an example in the next section where you can download the file and try it out on
your own micro:bit, or use the simulator. If you want to play around with the code and make some
changes, go ahead and click the Edit button in the widget, and it will open a MakeCode editor for you
to start hacking “Hello World.” Enjoy!
Download Your Program
Either copy and paste, or recreate the following code in your own MakeCode editor. You can also
just download this example by clicking the download button in the upper righthand corner of the code
window.
This will download your program file to your standard download location, probably the Downloads
folder on your computer, or whatever location you have set in your download preference.
You then simply click and drag your program file from its download location to your micro:bit drive,
which shows up as an external device.
That’s it!
Your micro:bit will flash for a few seconds, and then your program will start automatically. Yes! Win!
Note: You may need to disable your ad/pop-up blocker to see the simulated circuit!
Experiment 1: Blinking an LED
Introduction
LEDs are small, powerful lights that are used in many different applications. To start off, we will work
on blinking an LED, the basic introduction of microcontrollers and building circuits. You already did a
“Hello World” for the micro:bit itself, this is the next step. That’s right — it’s as simple as turning a
light on and off. It might not seem like much, but establishing this important baseline will give you a
solid foundation as we work toward more complex experiments.

Parts Needed
You will need the following parts:
1x micro:bit
1x Micro B USB Cable
1x micro:bit Breakout (with Headers)
1x Breadboard
1x Jumper Wire
1x LED
1x 100ΩResistor
Didn’t Get the SIK for micro:bit?
If you are conducting this experiment and didn’t get the Inventor’s Kit, we suggest using these parts:
Breadboard - Full-Size (Bare)
PRT-12615
18
micro:bit Board
DEV-14208
3

SparkFun micro:bit Breakout (with Headers)
BOB-13989
Jumper Wires Standard 7" M/M - 30 AWG (30 Pack)
PRT-11026
20
LED - Basic Red 5mm
COM-09590
Resistor 100 Ohm 1/4 Watt PTH - 20 pack (Thick Leads)
PRT-14493

Suggested Reading
Before continuing with this experiment, we recommend you be familiar with the concepts in the
following tutorial:
Light-Emitting Diodes — Learn more about LEDs!
How to Use a Breadboard — Learn the basics of using a breadboard!
Introducing the micro:bit Breakout
To extend the functionality of the micro:bit beyond what is already on the board, we developed a
micro:bit breakout.
This breakout board makes it much easier to use all of the pins available on the micro:bit edge
connector in a more user-friendly way. We also broke out ground and VCC (3.3 volts) for your
convenience.
The breakout board lines up with the pins of a breadboard. We recommend using a full-sized
breadboard with this breakout to give you enough room to prototype circuits on either end of the
breadboard. Also, for durability’s sake, insert the breakout pins about halfway into the breadboard so
there is support under the board for when you insert a micro:bit and/or pull it out.

Introducing the LED
A Light-Emitting Diode (LED) will only let current through in one direction. Think of an LED as a one-
way street. When current flows through the LED, it lights up!
When you are looking at the LED, you will notice that its legs are different lengths. The long leg, the
“anode,” is where current enters the LED. This pin should always be connected to the current
source. The shorter leg, the “cathode,” is the current’s exit. The short leg should always be
connected to a pathway to ground.
LEDs are finicky when it comes to how much current you apply to them. Too much current can lead
to a burnt-out LED. To restrict the amount of current that passes through the LED, we use a resistor
in line with the power source and the LED’s long leg; this is called a current-limiting resistor. With the
micro:bit, you should use a 100Ωresistor. We have included a baggy of them in the kit just for this
reason!
Hardware Hookup
Ready to start hooking everything up? Check out the wiring diagram and hookup table below to see
how everything is connected.
Polarized
Components
Payspecialattentiontothecomponent’smarkingsindicatinghowtoplaceiton
thebreadboard.Polarizedcomponentscanonlybeconnectedtoacircuitinone
direction.
Please note: Pay close attention to the LED. The negative side of the LED is the short leg,
marked with a flat edge.

Components like resistors need to have their legs bent into 90° angles in order to correctly fit the
breadboard sockets. You can also cut the legs shorter to make them easier to work with on the
breadboard.

Wiring Diagram for the Experiment
Having a hard time seeing the circuit? Click on the wiring diagram for a closer look.
Running Your Script
Either copy and paste, or re-create the following code into your own MakeCode editor by clicking the
open icon in the upper right-hand corner of the editor. You can also just download this example by
clicking the download button in the lower right-hand corner of the code window.
Note: You may need to disable your ad/pop-up blocker to interact with the MakeCode programming
environment and simulated circuit!

Code to Note
Let’s take a look at the code blocks in this experiment.
If you are having a hard time viewing this code, click on the image above to get a better look!
Forever
The
forever
block is a block that loops any other command blocks inserted into it over and over
again…forever. It starts from the top and executes your code in order working its way to the bottom
and then starts at the top again.
Digital Write
The
DigitalWrite
block enables you to turn a pin on or off. There is a dropdown option for which pin
you want to control, and it accepts a variable as the pins state. You use
1
as on and
0
as off. If you
prefer, you can also use Boolean states of
true
and
false
, but we will use
0
and
1
as our standard
throughout this guide.
Pause
If you were to just turn pins on and off with the
digitalwrite
block without a pause, the LED would
blink really, really fast. The
pause
block enables you to slow the micro:bit down and lets you control
the timing of things happening. It accepts a number or variable as the number of milliseconds you
want the micro:bit to pause. Think of this block as a stoplight for your code!
What You Should See
You should see your LED blink on and off at 1-second intervals. If it doesn’t, make sure you have
assembled the circuit correctly and verified and uploaded the code to your board, or see the
Troubleshooting section.

Troubleshooting
LED Not Blinking
Make sure you have it wired correctly and the correct pin to ground. Remember, short pin to ground;
long pin to signal.
Still No Success
A broken circuit is no fun. Send us an email, and we will get back to you as soon as we
Experiment 2: Reading a Potentiometer
Introduction
In this circuit you will work with a potentiometer. You will learn how to use a potentiometer to control
the brightness of an LED by reading a sensor and storing its 0–1023 value as a variable, then using
it as a brightness level for the LED.
Parts Needed
You will need the following parts:
1x micro:bit
1x Micro B USB Cable
1x micro:bit Breakout (with Headers)
Table of contents
Other Sparkfun Electronics Toy manuals