This Robot Arm can move in four directions and follow sets of instructions to pickup and move small objects. It's built from Lego Technic and moves using 4 servos controlled by a Raspberry Pi Zero.
Here are some videos showing the finished arm running some programmed sets of movements to perform tasks like picking up and moving some Lego bricks, putting a helmet on a Lego stormtrooper and playing a tune on an iPad xylophone app! I've setup a YouTube channel to host the videos.
The arm can be moved in four ways: the whole arm can be rotated from side to side, it can be raised and lowered, it can be extended away from the body, and the claw hand can be opened and closed to pick things up. It's controlled using the keyboard from a terminal/command line program running on the Raspberry Pi. Pressing the number keys 1 to 4 selects a servo to move and then the up and down keys move that servo.
It is really slow moving the arm using these simple controls, so I programmed it so that once you have moved the arm where you want it, you can save the position by pressing the S key. Multiple positions can be saved like this and the "program" can then be run by pressing the P key. The arm will then quickly run through the programmed movements. This allows it to do quite complex tasks, like picking up lego bricks and moving them. The program can also be saved to a file and reloaded later, so you don't have to reprogram it from scratch every time. The videos below show the arm running some preprogrammed movement sequences.
The arm is made entirely from parts from a few Lego Technic sets we already had at home. I think most of the yellow and black pieces I used were from the Technic Mine Loader (set 42049), although we have a few other smaller technic sets and lots of normal (non-technic) lego. I used the parts I had available, but most parts of the design could be modified to use whatever you have. As long as you have a few technic sets of standard parts, you could probably come up with a way to build something similar. I explain how each part is constructed in detail in the construction section.
Each of the moving joints is controlled by a servo. The 4 servos used are 9g micro servos, these are the little blue ones used in model airplanes. They can be bought on Amazon in packs of 5 or 6 for less than £10 (or similar amount in $ or €). By trial and error I came up with a lego assembly to hold the servo in place. A design similar to this is used in most of the arm joints. A detailed breakdown of the servo mount is shown on the construction page. The wiring and programming to get a single servo moving is explained on the simple example page.
The arm is controlled by a Raspberry Pi Zero computer. There is not much wiring needed to connect the servos to the Raspberry Pi. Each servo has a little ribbon cable with 3 wires:
These can be connected directly to the GPIO pins on the Pi for one or two servos. Some guides suggest connecting a resistor between the output pin and the servo control wire, but I have never found this to be necessary. Maybe it depends on the servos you have. I power down the Pi when connecting up servos to the GPIO pins. The wiring and programming for getting a single servo moving is explained on the simple example page. Have a look at my getting started guide to Raspberry Pi for more information on connecting up GPIO pins.
When you need to connect more components, I think it is best to use a small breadboard and jumper cables (as shown in the picture above). This allows you to quickly connect things up for prototyping without any soldering. They can be purchased cheaply from electronics shops or amazon. The downside to this approach is that you end up with a lot of wires and they can easily be pulled out of the breadboard by the arm moving about. In the picture you can probably just about see that the red (5V) and brown (ground) wires are connected to the red (+) and blue (-) power rails down the side of the breadboard. The small red and black wires then connect the power and ground to each of the servos. The 4 orange, yellow, green and blue wires connect the servos to the GPIO control pins on the Pi. I am using pins 3, 17, 27 and 22.
As I've been using the Raspberry Pi for several projects, I decided to build something tidier and more permanent for connecting things to it. So I soldered (very badly) the components and connectors for common inputs and outputs onto a little board which sits on top of the Pi Zero. This is not necessary for this project and I've explained how to connect everything up on a breadboard above, but you'll see it in some of the pictures. The board has several three pin connectors and a 4 pin one (which is really for i2c sensors) for power and I/O, which I used to connect the servos for the arm. There are also connectors for a distance sensor, sound output, an LED and a multi coloured LED, which I'm not using for this project.
Getting a single servo moving is explained on the simple example page. The programming of the arm is explained on the Programming page.