This project uses a Robotic Arm from Jarcar with a custom made Microbit interface, to enable the arm to be controlled by the Microbit.
This starter project is recommended for primary school students to make the coding easier so students can focus on the algorithms and actions. It provides functions that can be called to run the motors, buzzer and LEDs.
https://makecode.microbit.org/_UgiH2uXFDKma
When the page open, click Edit Code to access the coding page. To use the function blocks, click Advanced and then Functions.
Just before each function block you need a time block. To find the time block, click variables and then set time to ...
Here is an example of using a function. When button A is pressed, the time is set to 2000 ms (which is 2 seconds) and motor 2 will move upwards for 2 seconds.
Function |
Action: Each action is stopped after the specified time |
call m1Open |
Opens the jaws of the gripper |
call m1Close |
Closes the jaws of the gripper |
call m2Up |
Moves the “wrist” part of the arm upwards |
call m2Down |
Moves the “wrist” part of the arm downwards |
call m3Up |
Moves the “elbow” part of the arm upwards |
call m3Down |
Moves the “elbow” part of the arm downwards |
call m4Up |
Moves the base part of the arm upwards |
call m4Down |
Moves the base part of the arm downwards |
call m5Right |
Rotates the base part of the arm to the right |
call m5Left |
Rotates the base part of the arm left |
call forward |
Uses motor 3 and motor 4 together, to move the arm forwards |
call backward |
Uses motor 3 and motor 4 together, to move the arm backwards |
call redLight |
Turns on the red LED. (Recommended for the On Start block, to show that the Microbit is on.) |
call greenLight |
Turns on the green LED. |
call searchlight |
Turns on the LED on the arm. |
call buzzer |
Turns on the buzzer. (Note that he music blocks also work and give a wider range of sounds.) |
Coding in Javascript or Python
You can use this pin allocation table to plan your algorithm.
Pin Allocations |
||
Micro:bit Pin |
Action |
Pin setting |
O |
Buzzer |
0 = off, 1 = on or use Music blocks. |
1 |
Red LED |
0 = off, 1 = on |
2 |
Green LED |
0 = off, 1 = on |
3 |
M1, Gripper |
0 = off, 1 = on |
4 |
M1, Gripper |
0 = open, 1 = close |
6 |
M2, Wrist |
0 = off, 1 = on |
7 |
M2, Wrist |
0 = down, 1 = up |
8 |
LED “search light” |
0 = off, 1 = on |
9 |
M3, Elbow |
0 = off, 1 = on |
10 |
M3, Elbow |
0 = down, 1 = up |
13 |
M4, Base motion |
0 = off, 1 = on |
14 |
M4, Base motion |
0 = down, 1 = up |
15 |
M5, Base rotation |
0 = off, 1 = on |
16 |
M5, Base rotation |
0 = clock-wise, 1 = counter click-wise |