Introduction: Control Robot Arm With Simple Gestures

About: Engineer Editor Teacher Maker Block-based programming: micro:bit, Scratch, Kodular, App inventor

Controlling a robot with joysticks or a mobile application is a common practice. However, I like to challenge my students by exploring alternative ways to control robot arm movements, such as using simple hand gestures. In the provided video, it can be seen that waving a hand to the left or right will cause the robot arm to rotate counterclockwise or clockwise, respectively.


Supplies


  • MeArm V1.0 kit (acrylic parts)
  • Servo motors MG90S x4
  • 10cm Servo Male-Female Extension Wire
  • micro:bit x2
  • IO:bit V2.1 expansion board or any similar board that provides SVG connector with 5V supply for 4 servos
  • AA 1.5Vx2 battery pack or power bank with micro USB cable

Step 1: Design Ideas

Controlling real robots can be a complex task, but I would like to encourage my students to program and control the MeArm robot arm using micro:bit. By connecting 4 servo motors to micro:bit pins, I can use the "servo write" block command to move a servo to any desired angle.

First, decide which pins will be used to control the servo motors.

  • Servo under the base - connect to P13
  • Servo on the left side - connect to P14
  • Servo on the right side - connect to P8
  • Servo at the grip - connect to P12

To enhance the mobility of the robot arm, I plan to utilize radio communication between two micro:bits. This will enable me to control the robot arm wirelessly. For the communication to work, both micro:bits must be configured to the same radio group. The radio group can be assigned any value between 0 to 255. In this project, the radio group is set to 1.

To make controlling the robot arm more interesting, I came up with an idea to use a simple gesture. For example,

  • Tilt micro:bit to the left - the robot arm rotates counterclockwise.
  • Tilt micro:bit to the right - the robot arm rotates clockwise.
  • Tilt micro:bit to the front - the robot arm moves forward.
  • Tilt micro:bit to the back - the robot arm moves backward.
  • while pressing button B and
  • Tilt micro:bit to the back - the grip moves up
  • Tilt micro:bit to the front - the grip moves down
  • To open or close the grip, just press button A.

The micro:bit uses an on-board accelerometer sensor to detect changes in its orientation, specifically the roll and pitch angles. With this feature, students can create programs that detect the direction in which the micro:bit board has been tilted. They can then use these programs to send commands to another micro:bit, to control the movement of a servo motor according to the user's gesture.

The format of those commands is simple. for example, sending "Base" and the number of degrees the servo rotates - will cause the servo motor located at the base to rotate from its current angle, while plus and minus numbers determine the direction of rotation.

Here are 5 basic commands for controlling the robotic arm:

  • To rotate the base of the arm, use the command "Base +/- nnn" where "nnn" indicates the number of degrees you want to move the servo. A positive value will rotate it clockwise, while a negative value will rotate it counterclockwise.
  • If you want to move the arm forward or backward, use the command "Stretch +/- nnn". This will rotate the servo on the right side of the arm.
  • To move the grip up or down, use the command "Level +/- nnn". This will rotate the servo on the left side of the arm.
  • Finally, to toggle the state of the grip between open and closed, simply use the command "Grip 0".

Step 2: Assembly the MeArm Robot Arm

In this tutorial, I will be using the MeArm robotic arm kit as an example. The MeArm kit is a small and affordable robotic arm designed for educational purposes and hobbyist projects. It is highly popular among students, educators, and makers who are interested in robotics. The assembly and programming of the MeArm kit provide hands-on experience in building and controlling robotic devices. You can easily find tutorials on the web that provide step-by-step instructions for assembling the kit.

Step 3: Prepare IO:Bit Expansion Board

IO:bit V2.1 expansion board provides SVG connectors for all pins, making it easy to connect with servo motor cables. However, since servo motors require a 5V power supply, some configuration is necessary. You can configure all V-pins to either 3.3V or 5V by using a single jumper. Make sure to insert the jumper on the 5V side for proper functioning.

Step 4: Connect the Wires

To set up your device, follow these steps:

  1. The servo located at the grip is in the farthest position, so it requires a 10cm Servo Male-Female Extension Wire to increase the wire length.
  2. Connect four servos to the following pins:
  3. The servo located under the base should be connected to P13
  4. The servo located on the left side should be connected to P14
  5. The servo located on the right side should be connected to P8
  6. The servo located at the grip should be connected to P12
  7. Attach the IO:Bit to the end of the base.

Step 5: Program Micro:bit

If you want to make coding easier for most students, I would recommend using MakeCode. However, in this particular case, I suggest using an enhanced feature called MakeCode Multi (https://makecode.microbit.org/---multi#). MakeCode Multi allows you to write programs on both the robot and remote control sides simultaneously, thanks to two separate windows.

The program on the remote control side is straightforward. It reads both the roll and pitch angles from the accelerometer sensor. If the orientation changes to more than 30 degrees or less than -30 degrees, it will trigger the program to send a command to the robot arm to move according to its design.

In the initialization state of the robot arm program, we need to set the initial angles (save in variables) and instruct all four servo motors to move to the starting angles. When it receives a command from the remote control, it interprets which servo motor the command is for.

To improve program readability, I created four functions to calculate a new angle for the servo and move the servo to that angle. In each function, I used a "constrain" block to limit the angle between two values.

Note

In order to communicate, both programs must have set the radio group to the same number (0-255).

Step 6: Ready to Operate

After successfully flashing the code into both micro:bit boards, we are now ready to operate the robot arm. Here are the steps you need to follow:

  1. Insert the micro:bit into the IO:Bit slot on the robot arm.
  2. Power up the IO:Bit using a power bank and a USB cable.
  3. Insert 2 AA or AAA batteries into the battery pack.
  4. Plug the battery pack into the micro:bit power connector.
  5. Turn on the switch on the battery pack.
  6. Finally, start moving your hand and have fun controlling the robot arm.

Step 7: Trick to Surprise Your Students

To surprise my students, I decided to add a special trick to the lesson.

As you may know, the micro:bit is equipped with a magnetometer sensor that can detect magnetic field strength. This sensor is located on the back of the micro:bit board (as shown in the picture). I attached a neodymium magnet to my little finger, so when I closed my hand, the sensor detected a strong magnetic force.

After some experimentation, I found that the sensor reported a value of more than 300uT (micro Tesla) when it approached the neodymium magnet. Instead of checking whether button B was pressed, I modified the program to detect high magnetic force. This way, when I closed my hand, I was able to control the grip to move up or down. And when I opened my hand, I could control the robot arm to move forward or backward.

I use a wristband to securely attach the micro:bit to my palm, and a rubber band to fasten the battery pack to my wrist. To conceal the neodymium, I wrap a bandage around my little finger. That's my secret!

Step 8: Homework for My Students

I have attached micro:bit to my palm in such a way that it is difficult for me to press button A to open or close the robot's grip. However, there are some alternatives that I want my students to try. 

  • The first way is to wire an external button to P5 and GND. This means that the external button will act as another button A and there will be no need to modify the program. 
  • Another way is to connect two wires to P1 and GND and make a touch-sensitive switch instead of using any physical switch. Of course, this approach will require a few modifications in the program.
Robotics Contest

Participated in the
Robotics Contest