Professional Documents
Culture Documents
Outreach - Bionic Hand Instructions
Outreach - Bionic Hand Instructions
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.
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.
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?
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.
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!
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).
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!
Can you recreate this for all the fingers on the bionic hand?