Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Task 1 – It’s Alive!

Can you follow the instructions below to get the first movement from your bionic hand? To start, we’re going to test tensing and relaxing one of the fingers,
to make it curl.

Instruction Visual steps Why?


1. Click on “New Project” We need a new blank project to start coding the bionic
hands.

2. Click on Advanced This will give us a wider range of “drawers”. Each of the
drawers will have a different functionality, similar to
Scratch!

3. Click on “Pins”. You might This will give us the options to control the outputs signals
have to scroll down to see sent from the micro:bit to the bionic hand.
this option!
4. Find the block “analog write This is the block that controls the signal sent to the hand.
pin p0 to 1023”
Normally, these can be a value from 0 (0%) to 1023 (100%
signal). For the hand, we have 10 (0%) to 180 (100%).

5. Drag the block into your Any block inside Forever is repeated forever and ever.
Forever block. Change p0 to
be p7. Here we tell the microbit to send 180 (100%) signal to the
finger attached to pin 7.
Change 1023 to be 180. This
is the maximum value we If we downloaded the code now. The finger would curl, but
can send. then stay that way.

We want the finger to curl and then go back to the starting


position.
6. Go to the “Basic” drawer. To do this, we need to add in a pause between our
Find the pause block. instructions.
7. Drag this into your Forever Setting the pause block to 2 seconds (or 2000 milliseconds)
block, underneath your gives the finger enough time to move before the micro:bit
“analog write” block. Change send the next instruction.
100 to be 2 seconds by
pressing the small
downwards arrow and
selecting the 2 seconds
option.
8. Go back to “Pins”. Select Here is our second instruction to tell the finger to return to
another “analog write pin” the starting position.
block. Place it inside your
Forever block and ensure However, in the second block, we need to make sure that
you change p0 to p7. we set the value to 10 (0%).

In your second “analog write


pin” block, change 1023 to
be 10.
9. Go back to Basic and find the Setting the pause block to 2 seconds (or 2000 milliseconds)
“pause” block. Put this gives the finger enough time to move before the Forever
inside your Forever loop, block repeats itself
below your second “analog
write pin” and change it to 2
seconds.

10. Download! Click the purple


download button on the
bottom left of the screen.
Make sure your micro:bit is
plugged in!
11. Click “SAVE” and the “Open
Folder” on the bottom of the
screen.
12. Click and drag the file onto
MICROBIT. Wait until the
orange light on the back of
the micro:bit has stopped
flashing.

Challenge!

Can you modify this code to curl one of the other fingers of the hand? What would you need to change? (Look at the
micro:bit breakout board to see which other pin numbers can be used)
Task 2 – High Five!
Now we have movement, how do we get all the fingers to move at the same time?

Instruction Visual steps Why?


1. Make sure you have all the We’re going to be building on this task, so double check you
code from Task 1 have all the code before moving on to the next step.

2. Right click on the top Knowing how to duplicate blocks makes your coding so
“analog write pin” block. much quicker.
Click Duplicate.
3. Put the duplicated block This sends the 100% signal to the finger attached to the
under your first analog write motor controlled by Pin 8.
block.

Change p7 to be p8.

4. Duplicate the block again. Now our code will set all fingers to curl, as we send a signal
Change p7 to be p11, and of 180 (100%) to each of the motors controlling a finger.
put under your “analog write
pin p8” block.
5. Now duplicate the “analog Now our code sends 180 (100%) signal to all of the fingers,
write pin p7 to 10” block. Do causing them to curl.
this twice, and put them
after one another. It pauses for 2 seconds (2000 milliseconds)

Change the second of the And then the micro:bit send a signal of 10 (0%) to cause the
blocks from p7 to p8. fingers to relax into their original position
Change the third from p7 to
p11.

6. Download! Click the purple


download button on the
bottom left of the screen.
Make sure your micro:bit is
plugged in!
7. Click “SAVE” and the “Open
Folder” on the bottom of the
screen.
8. Click and drag the file onto
MICROBIT. Wait until the
orange light on the back of
the micro:bit has stopped
flashing.

Challenge!

What can you change in the code to get the fingers to curl and relax in a sequence? Think about the order of your
blocks, and which you might need to duplicated to get this effect. Some fingers are attached to the same motor, so
some fingers will have to move at the same time!
Task 3 – Jazz hands!
The micro:bit has a small, inbuilt sensor called an accelerometer. The accelerometer detects movement on an XYZ axis, and we can use this to control the
movement of the bionic hand!

Instruction Visual steps Why?


1. Start a brand new We’re going to use this variable to store the data
project. Click on the red sent by the accelerometer on the micro:bit.
Variables drawer, and
then on the small button
at the top that’s called
“make a variable”. Call
your new variable
“xReading”
2. Go back to Variables and The information contained within xReading will
drag in “set xReading to change each time the micro:bit goes through the
0” inside your Forever Forever loop.
loop
3. Go to the Math drawer If we have any fractions, the “round” block will
and find the block called round the number on the right (currently a zero)
“round 0”. Place it on up to the nearest whole number. What do you
the 0 of the “set think would happen if the number was 2.1 or
xReading” block. 1000.9?

4. Go back to the Math Since the minimum value of the accelerometer is


drawer and find the -1023 and the maximum value of the
division block. Put it on accelerometer is +1023, the division block helps
the 0 of the “round” divide these values into a number the motors
block. can understand (minimum 10 and maximum of
180)
5. Go back to the Math Almost there! This helps us to use the
drawer and find the acceletometer data for our motors!
addition block. Put it on
the 0 of the “round”
block. If it’s a bit fiddley,
you can ask for help!

6. Go to the Input drawer. What this says is “take the value of the
Find the block called accelerometer (which can be -1023 to +1023)
“acceleration (mg) x”. and add it to 1024 (so the reading will now be 1
Drag the block into the 0 to +2047).

Divide this number by 11 (so if the maximum


value was +2047, it roughly divides to be 180).

Then round the number so it is a whole number,


and place it in the variable know as xReading.
Phew
7. Go to the Pin drawer and This will help us control the motor attached to
drag an “analog write p7 – which finger will it control?
pin” block into your
Forever block. Change
the pin to be p7.

8. Go back to the Math Since the motor will only work with values
drawer. Find the between 10 and 180, this block will help
“constrain 0 between 0 “constrain” or restrict a value from going below
and 0” block. Drag the or above a certain point
block on top of the
number of your “analog
write pin”
9. Go to the Variables This is the value we’re going to be sending to the
drawer and find motor
xReading. Drag in the
block to the first 0 in
your “constrain” block
10. Constrain xReading This block says “set pin 7 to the value of
between 10 and 180. xReading (but only a value that’s between 10
Change the first 0 to be and 180)”
10 and the second 0 to
be 180. If xReading is 0, this block will change the value
to be 10. If xReading is 188, this block will
change the value to be 180.
11. Download! Click the
purple download button
on the bottom left of the
screen. Make sure your
micro:bit is plugged in!
12. Click “SAVE” and the
“Open Folder” on the
bottom of the screen.
13. Click and drag the file
onto MICROBIT. Wait
until the orange light on
the back of the micro:bit
has stopped flashing.

Challenge!

Slowly tilt the micro:bit backwards and forwards. What happens?

Can you recreate this for all the fingers on the bionic hand?

Can you get the hand to crawl on the table?

You might also like