MonkMakes 00063 User manual

Instructions:
ELECTRONICS STARTER KIT
FOR MICRO:BIT
Rev 4a.

TABLE OF CONTENTS
Parts ..........................................................................................................................3
Making the Projects...................................................................................................4
Getting Started...........................................................................................................7
Project 1. Movement Alarm....................................................................................10
Project 2. Lighthouse...............................................................................................12
Project 3. Shout-o-meter..........................................................................................14
Project 4. Thermometer...........................................................................................17
Project 5. Fan Speed Controller...............................................................................20
Project 6. Automatic Fan.........................................................................................24
Project 7. Magic Music............................................................................................26
The JavaScript Blocks Editor..................................................................................28
Using MicroPython..................................................................................................30
Troubleshooting.......................................................................................................31
What Next?..............................................................................................................32
Notes........................................................................................................................33
MonkMakes.............................................................................................................36
Page 2

PARTS
micro:bit, AA battery and USB lead are not included in this kit.
Before you do anything else, check that your kit includes the following items:
Quantity
1 MonkMakes Speaker for micro:bit
(play sounds from your micro:bit)
1 MonkMakes Switch for micro:bit
(switch things on and off or control the
brightness of a light or the speed of a motor)
1 MonkMakes Sensor Board for micro:bit
(sense sound, temperature and light)
1 Set of alligator clip leads (10 leads) to connect
things together
1 Small motor with fan
1 Single AA battery box (battery not included) to
power the light bulb and fan
1 MonkMakes 1V Bulb
Page 3

MAKING THE PROJECTS
Software
Before connecting boards to your micro:bit install the program for the project onto
the micro:bit. This makes sure that pins are correctly configured as inputs and
outputs before you connect up the electronics.
This kit comes with programs for both the JavaScript Blocks Editor and for
MicroPython. If you are new to programming, then the Blocks editor is the best
place to start. If you want to use the MicroPython versions of the programs, then
please see the section Using MicroPython later in this booklet.
The Blocks editor program allows you to program your micro:bit directly from the
browser on your computer. All the programs for this kit are listed on a web page for
this kit's software at: https://monkmakes.com/mb_2a shown below.
Clicking on one of the programs will open it in your browser so that you can then
install it on your micro:bit.
Page 4

Alligator Clips
The projects in this kit are assembled by connecting your micro:bit to one or more of
the MonkMakes boards using alligator clips. You have to be a bit careful how you
connect the clips at the micro:bit end. The correct way is to connect the clips
vertically as shown below.
Connecting the alligator clips like this prevents any accidental connections between
the large connectors with the holes in and the much smaller connectors (gold lines
in the photo above)
The Motor
To stop the motor falling over, connect the alligator clips as shown below.
Page 5

Building a Project
The micro:bit and the MonkMakes boards are pretty robust when it comes to
connecting things up the wrong way around, but it's a good idea to unplug your
micro:bit from your computer while you are wiring things up. Then check it over
carefully before connecting your micro:bit to your computer.
Each project includes a wiring diagram, like the one below. This shows you what
needs to be connected to what. It suggests the colors of lead to be used for each
connection. The project will still work just fine, whatever color of lead you use, but it
makes it easier to see what's going on if you stick to the color scheme, especially
using red for 3V power connections and black for the ground connection.
Page 6

GETTING STARTED
To get you started with your kit, please follow the steps below. This does not use
any of the MonkMakes add-on boards, so for now you don't need the alligator clips.
If you have already used your micro:bit for other things, you can probably skip this
section.
Step 1. Plug your micro:bit into your computer.
Connect your micro:bit to a free USB port on your computer.
If your micro:bit is new, then its LED display will start displaying messages and
showing off various features of the micro:bit. You are going to replace this program
currently running on your micro:bit with a new one.
Step 2. Open The Blocks Editor
To install the new program (incidentally the program is called welcome) onto your
micro:bit, you first need to open it in the Blocks Editor. You can do this by going to
the following page on your computer's web browser:
https://monkmakes.com/mb_2a
Page 7

Click on the project called welcome. This is what you should see when you click on
it.
Step 3. Install the Program
Next, you are going to send the welcome program to the micro:bit.
Click on the “Download” link at the bottom of the page. This will download a file for
the program ending in .hex. You will also see the prompt below.
As the prompt says, this hex file needs to be moved onto the micro:bit. The
micro:bit will show up as a USB drive on your computer. In other words, you need to
Page 8

drag the hex file from your Downloads folder onto the micro:bit icon in the file
explorer just as if the micro:bit were a USB flash drive.
If you are using a Mac, Linux or Raspberry Pi computer the process is the same,
but the file explorer tool will be different.
As soon as the hex file is dragged onto the micro:bit icon, a yellow LED on the back
of your micro:bit will start to flicker furiously as the program is flashed onto the
micro:bit. As soon as the flashing has finished, the welcome program will start and
display the message: Your electronics adventure begins.
Congratulations, you are now ready to move on to Project 1!
If you want to learn more about the Blocks Editor, then see the section The Blocks
Editor later in this booklet.
Page 9

PROJECT 1. MOVEMENT ALARM
You will need:
•micro:bit
•MonkMakes Speaker for micro:bit
•Program: P1 Alarm
Flash the program P1 Alarm onto your micro:bit
(see page 8 for instructions on flashing programs
onto your micro:bit). Then connect the Speaker as
shown to the right.
Try moving your micro:bit. As soon as you do, you
should hear a tune start to play to indicate that the
alarm has been triggered.
How it Works
The program uses the micro:bit's built in accelerometer to measure any force acting
in the z dimension (vertically). If the micro:bit is lying completely flat this will be
-1023, but when the micro:bit is picked up, the force will change.
When the program first starts, it saves the current acceleration reading in a variable
called z. The forever loop then repeatedly checks the acceleration and if it has
fallen from its initial value (z) by more than 50 the alarm is sounded.
Page 10

Try tweaking the number 50, to alter how sensitive the alarm is. You can also pick
different tunes to play in the start melody block.
MicroPython Code
If you want to use the MicroPython versions of the programs rather than the Block
Editor code, then please see the section near the end of this booklet called Using
MicroPython for instructions on downloading and using the code.
Here is the MicroPython code for this project.
from microbit import *
import music
z = accelerometer.get_z()
while True:
if accelerometer.get_z() < z - 50:
music.play(music.BA_DING)
Page 11

PROJECT 2. LIGHTHOUSE
You will need:
•micro:bit
•MonkMakes Switch for
micro:bit
•MonkMakes 1V Bulb
•Single AA battery holder
and battery
•Program: P2 Light House
Flash the program P2 Light House
onto your micro:bit (see page 8) and
then wire up the Switch, battery and
light-bulb as shown to the right. Make
sure that the connection to the
negative end of the bulb (marked -) goes to the negative side of the battery and also
that the negative side of the battery is connected to the negative side of the switch.
This project will make the light bulb blink on and off.
You might like to make yourself a cardboard structure as the lighthouse and fix the
light bulb on top.
How it Works
Here is the code for the project.
First Pin P0 is turned on using a digital write block. The 'pause' block then ensures
that it stays on for 1000 milliseconds (1 second) before it is turned off. There then
follows another pause of 2 seconds before the cycle repeats itself.
Page 12

MicroPython Code
If you want to use the MicroPython versions of the programs rather than the Block
Editor code, then please see the section near the end of this booklet called Using
MicroPython for instructions on downloading and using the code.
Here is the MicroPython code for this project.
from microbit import *
while True:
pin0.write_digital(1)
sleep(1000)
pin0.write_digital(0)
sleep(2000)
Page 13

PROJECT 3. SHOUT-O-METER
You will need:
•micro:bit
•MonkMakes Sensor Board for
micro:bit
•Program: P3 Shoutometer
Flash the program P3 Shoutometer onto your
micro:bit (see page 8) and then connect up
the Sensor board as show to the right.
Make a noise near the microphone section of
the MonkMakes Sensor Board and you
should see the LEDs on the micro:bit light to
show the volume. The louder the noise, the
more LEDs will be lit.
How it Works
The microphone turns sounds into an electrical signal that looks something like this:
The voltage at the microphone output of the sensor board will always be between 0
and 3V, the signal swinging above and below a midpoint of about 1.5V. The number
of LEDs lit is calculated from how much this signal voltage is above the signal mid-
voltage (1.5V).
Page 14

Here is the code for the project:
The function analog read pin gives a number between 0 and 1023 depending on the
voltage at pin0. Since pin0 is connected to the microphone, the signal will vary
between 0 and 1023 as the sound wave oscillates. 511 is subtracted from the
reading to get the midpoint of the signal. This means that sometimes the result to
be displayed by the plot bar graph block will be negative, but that doesn't matter as
the bar graph plotter will just ignore those values.
The block plot bar graph lights more LEDs the bigger the number supplied to it. The
image below shows the result of a particularly loud noise!
Page 15

MicroPython Code
If you want to use the MicroPython versions of the programs rather than the Block
Editor code, then please see the section near the end of this booklet called Using
MicroPython for instructions on downloading and using the code.
Here is the MicroPython code for this project.
from microbit import *
def bargraph(a):
display.clear()
for y in range(0, 5):
if a > y:
for x in range(0, 5):
display.set_pixel(x, 4-y, 9)
while True:
sound_level = (pin0.read_analog() - 511) / 100
bargraph(sound_level)
Page 16

PROJECT 4. THERMOMETER
You will need:
•micro:bit
•MonkMakes Sensor Board for
micro:bit
•Program: P4 Thermometer or P4
Thermometer F (for Fahrenheit)
Flash the program P4 Thermometer (for
degrees C) or P4 Thermometer F (for
Fahrenheit) onto it (see page 8). Then
connect the Sensor board as shown.
Your micro:bit will display the temperature
of the MonkMakes Sensor Board's
temperature sensor (shown by the
thermometer symbol).
Try putting your finger on the sensor and
you should see the temperature start to
rise.
How it Works
The temperature sensor uses a component called a thermistor. A thermistor is a
component that resists the flow of current to a varying degree depending on its
temperature.
For this kind of thermistor, the greater the temperature, the less it resists the flow of
current. This effect is used to measure the temperature.
The maths is necessary to convert the reading from the thermistor into a
temperature in degrees C. If you would prefer the reading to be in degrees
Fahrenheit then use the program P4 Thermometer F.
Calibration
If you want to make your thermometer more accurate, this section will show you
how to calibrate it.
To calculate the temperature whether in degrees F or C, the analog reading is first
Page 17

multiplied by a number (A) the result is then divided by another number (B) and
then a positive or negative final number C is added to the result. To make your
thermometer more accurate you can use the program P4 Calibrate to find the
analog reading for two known temperatures (using a second thermometer) and then
calculate new values of A, B and C.
Step 1. Flash the program P4 Calibrate onto your micro:bit with the Sensor Board
wired up as described above.
Step 2. Record the temperature (either in F or C) using a second thermometer
placed close to the temperature sensor on the board. Then press button A and
record the value displayed. You can write both these values in the table below as I
have here, where the temperature in C was recoded as 18 degrees and the sensor
reading 460.
Step 3. Wrap an ice cube in a plastic bag and hold it against both the temperature
sensor on the Sensor Board and the second thermometer at the same time. Wait
for 30 seconds and then record both the second thermometer reading and the
reading displayed by the micro:bit (when you press button A). In this case the
readings were 0 degrees C and 345. Write them in the table too.
Step 4. Calculate A, B and C using the formulas in the table:
Room temperature using thermometer (t1) 18
Room temperature reading on Sensor (r1) 460
Cold temperature using thermometer (t2) 0
Cold temperature reading on Sensor (r2) 345
A = t1 – t2 18
B = r1 – r2 115
C = t2 – (A / B) * r2 0 – (18/115) * 345 = -54
Once you have the values of A, B and C, you can change these value in your block
program.
MicroPython Code
If you want to use the MicroPython versions of the programs rather than the Block
Editor code, then please see the section near the end of this booklet called Using
MicroPython for instructions on downloading and using the code.
Here is the MicroPython code for the Centigrade version of this project.
from microbit import *
Page 18

while True:
reading = pin1.read_analog()
temp_c = reading * 0.157 - 54
display.scroll(str(temp_c))
Page 19

PROJECT 5. FAN SPEED CONTROLLER
You will need:
•micro:bit
•MonkMakes Switch for
micro:bit
•AA Battery holder and
battery
•Motor with fan attached
•Program: P5 Fan Speed
Flash the program P5 Fan Speed
onto your micro:bit (see page 8).
Connect up the components as shown
to the right. Note it doesn't really
matter which way around the motor
leads are connected. Reverse them
and the motor direction will reverse.
The micro:bit display will show a
number between 0 and 9 indicating
the fan's speed. Use button B (on the
micro:bit) to increase the speed and
button A to decrease the speed.
How it Works
This project uses the MonkMakes Switch to provide pulses of power of varying
length to the motor.
The code is the most complicated so far. It uses quite a few variables that are
defined in the on start block.
•min_power – This should be set to the minimum power output value that
makes the motor just start to turn. This varies a bit between motors. Try
the default value of 600, but if the motor doesn't turn when you press
button B to set the speed to 1, you may need to increase this value to
perhaps 700 or more.
•max_power – This is the maximum power, you can leave this as 1023
•power_step – This is the power range divided by 9 and will be the amount
of power change that results from one step more of speed.
•Speed – The speed from 0 (off) to 9 (maximum)
Page 20
Table of contents
Popular Control Unit manuals by other brands

powersoft
powersoft LiteMod 4HC user guide

Camozzi
Camozzi KDV Series Use and maintenance instructions

Veichi Electric
Veichi Electric VC-4AD user manual

CDTech Electronics
CDTech Electronics CDW-61723DE-00 manual

api technologies corp.
api technologies corp. SmartStep 150T Installation & operating instructions

Bosch
Bosch Rexroth IndraControl VAC 31 Assembly instruction

Trinity Highway
Trinity Highway INGAL SS180 M Assembly manual

Comtech EF Data
Comtech EF Data Vipersat CDD-562L Installation and operation manual

Viessmann
Viessmann VITOTRONIC 300-K Installation and service instructions

Jakka
Jakka CONTROL KIT 5 user manual

Nexo
Nexo Digital Patching Unit quick start

GF
GF DIASTAR DN65 instruction manual