Introduction: Arduino Robot Arm Mixologist

About: The RobotGeek team is a 6-man operation that wants to make it even easier to use Arduino to make electronics and robots. Check out our instructables and robotgeek.com for all of our awesome kits.

"But wait," you say, "I thought RobotGeek already published an instructable about using a robot arm to deliver drinks!" To which we say, "Yes, but not like this." The last project could dish out one drink to multiple people. This project mixes the perfect beverage with style and class. We split this up into two separate projects because this one is a bit more advanced than the last. Welcome to the Robot Arm Mixologist. This project utilizes a RobotGeek Snapper Arm with a Pumping Station to mix liquids from multiple containers.

We will be using a Demo code to show off how to make alterations to the code generated by the Arm Link Software. We will use this to program the arm's movements.

Step 1: Project Parts List

Step 2: Assembly

Follow the guides for each of the components:

Snapper Arm Assembly Guide

Pumping Station Assembly Guide

RobotGeek LCD Assembly Guide

Instead of attaching the gripper to the end of the snapper, we will be making a spout system and running the silicone tubing up the arm, from the pump to the spout. Pictured is a way to make the input end. You can achieve a similar effect with a large straw.

Raise the Snapper arm up on the 100mm Standoffs to clear the tops of the containers you're pulling from.

Attach the LCD, pushbutton, and joystick where they can be easily reached, and out of the path of the arm.

Step 3: Wiring

Device Sensor Shield Port
Servos
Base Rotation RobotGeek Servo Digital 3
Shoulder RobotGeek Servo Digital 5
Elbow RobotGeek Servo Digital 6
Wrist RobotGeek Servo Digital 9
Outputs
Relay RobotGeek Pumping Station Digital 13
LED 1 RobotGeek LED Driver Digital 4
LED 2 RobotGeek LED Driver Digital 7
LED 3 RobotGeek LED Driver Digital 8
LED 4 RobotGeek LED Driver Digital 12
LCD RobotGeek LCD Screen I2C
Inputs
Select Stick RobotGeek Joystick (Vertical) Analog 0
Activation Button RobotGeek Pushbutton Digital 2

Make sure that the 6V power supply is running the pump, and the 7V power supply is plugged into the Arduino. The Power pins on the Sensor Shield should be set to VIN to supply the full 7V power to the servos in the Snapper Arm.

Step 4: Demo Code Part 1: Installing and Testing

The Demo Code can be found here:

https://github.com/robotgeek/SnapperArm

Unzip and find the Demo under:

SnapperArm -> Demos -> SnapperArmPlayBackMixologist

Load the sketch onto your board, and play with it a bit. If everything works as expected, your wiring and build are correct. If you are happy with this configuration, you can call it a day here, and start partying with your robot arm mixologist, but if you would like to know how to program the movements and add/change drinks, continue on! There is much to learn!

Step 5: Software Set Up

In order to make our own sequences, we're going to need to set up the Arm Link software. This isn't hard, but it is involved, so make sure to follow along carefully.

Download the Snapper Arm Sketches


  1. Download the Snapper Arm Sketches from Github.
  2. Unzip to your Arduino Sketches folder. You will need to know where this is later.

Setting up the Arm Link Library and Firmware

  1. Download the ArmLinkLibrary and Extract the ArmLink folder to your Arduino libraries folder.
  2. Open the Arduino IDE, and open
    File -> Examples -> ArmLink -> SnapperArmLinkSerial
  3. Uncomment one of the following lines:
    //#define GRIPPER_TYPE ROBOT_GEEK_9G_GRIPPER
    #define GRIPPER_TYPE ROBOT_GEEK_PARALLEL_GRIPPER

    It doesn't matter which, because we will not be using a gripper for this project

  4. Make sure your Robot Bartender is plugged into your PC via USB, and upload the firmware.

Setting up Processing

  1. Download and extract Processing 3 for your operating system
  2. Open
    Tools -> Add Tool...

    and in the window that pops up, click on the Libraries tab.

  3. Search the library for G4P and install it.
  4. Search the library for Video, and install the Video Library authored by the Processing Foundation

Setting up Arm Link

  1. Download and extract the ArmLink Software for Processing 3
  2. Make sure your Robot Bartender is plugged into your PC via USB and open ARMLink.pde. Processing 3 should open to a window with the InterbotiX Arm Link code.
  3. Press the Triangle button in the top left corner of the window. This will run the Arm Link Software.
  4. Select the COM port your Bartender is on and click Connect.

Step 6: Making the ArmSequence File

  1. Once you are connected to your Bartender, the Arm Link software will display the Control Panel, Sequence Panel, I/O Panel, and Mode Panel below the Setup Panel.
  2. Click on Cylindrical in the Mode Panel. This mode gives us easy to understand control with good reach. The Control Panel will change.
  3. Tick the Save Digital Outputs box.
  4. Click on New Pose. This will let us save each position we set the arm to.
  5. Tick the Auto Update box at the bottom of the control panel. This will move the arm as we adjust the sliders in real time.
  6. Once the arm is in a position you'd like it to be in, you can click the Save Pose button to save it to the active sequence.
  7. For each pose you want, hit new pose, adjust the sliders to move the arm to the position you want, and hit Save Pose. If you want to turn the pump on, tick box 13 in the Digital Output section of the I/O Panel. Mind the Pause (Ms) section of the control panel. This will be the amount of time your pump will stay on. Be sure that if you would like the pump to turn off before moving that the next pose you create has box 13 unchecked.
  8. Once you have all the poses you want, click the Save to File button in the Sequence Panel.
  9. Navigate to the
    SnapperArm -> SnapperArmPlayback
    folder that you downloaded earlier, and click Open to save.

Step 7: Demo Code Part 2: Altering Automatically Generated Files

With SnapperArmPlaybackMixologist.ino loaded in the Arduino IDE, it should also load GlobalArm.h, Kinematics.h, and armSequence.h. We will be taking a look at armSequence.h.

To begin with, each of the movements here were from 4 separate armSequence files generated by Arm Link. For the Mixologist, we combined these files into a single armSequence file by adding each void playSequence, and changed a few things in the generated code.

volatile int playState1 = 0; // 0 = stopped 1 = playing
volatile int playState2 = 0; // 0 = stopped 1 = playing
volatile int playState3 = 0; // 0 = stopped 1 = playing
volatile int playState4 = 0; // 0 = stopped 1 = playing
We keep one of the headers, and add a volatile int playState for each of the ArmLink generated sequences.
void playSequence1()

We separated every playState and playSequence() by adding a number, so we can call upon them as needed in the main code. Pay attention, there are many instances of playState throughout each sequence, and all of them must be changed for this to work when you make your own movement set.

If you'd like to make custom sequences for different sized containers, or to add more arm sequence positions, pay attention to the layout in the default armSequence.h, make your own armSequence.h in ArmLink, and manually add it to the armSequence.h for the mixologist using the tips we've pointed out here. It's not hard, it's just involved, so try to keep it organized.

Step 8: Demo Code Part 3: Adding and Changing Drinks

Take a look at SnapperArmPlaybackMixologist.ino. There is an array containing all the drinks that can be served with the arm. If you were to replace the colored water with other beverages to be mixed, that would certainly warrant renaming these.

String drinkLine[12] = {"Select Drink:",
                        "Red", 
                        "Green",
                        "Blue",
                        "Yellow",
                        "Red and Green",
                        "Red and Blue",
                        "Red and Yellow",
                        "Green and Blue",
                        "Green and Yellow",
                        "Blue and Yellow",
                        "Please Wait..."
                        };
Keeping "Select Drink:" and "Please Wait..." intact, changing the names here will change them on the screen. Be aware that the LCD is only capable of displaying up to 16 characters per line, so anything over that will not be displayed.

You can also tell the arm which reservoirs to pull from later in the code by having it call upon a different playSequence():

      else if (drinkSelectCounter == 7)
      {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED4, HIGH);
        playSequence1();
        playSequence4();
        digitalWrite(LED1, LOW);
        digitalWrite(LED4, LOW);
      }
This snippet of code lines up with the "Red and Yellow" drinkLine. If, for instance, you wanted it to instead serve Red, Green, and Blue, you would change the name in the drinkLine to something such as "Red Green Blue":
String drinkLine[12] = {"Select Drink:",
                        "Red", 
                        "Green",
                        "Blue",
                        "Yellow",
                        "Red and Green",
                        "Red and Blue",
                        "Red Green Blue",
                        "Green and Blue",
                        "Green and Yellow",
                        "Blue and Yellow",
                        "Please Wait..."
                        };
Then, later in the code, we would add the appropriate playSequences and write to the LEDs corresponding to the drinks we were serving, like so:
      else if (drinkSelectCounter == 7)
      {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, HIGH);
        playSequence1();
        playSequence2();
        playSequence3();
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
        digitalWrite(LED3, LOW);
      }
and
  else if (drinkSelectCounter == 7)
  {
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
    digitalWrite(LED3, HIGH);
    digitalWrite(LED4, LOW);
  }
This is just an example of what you can do. Dream something up, and try it out!

Step 9: You're Done!

Heck, you've got yourself a robotic arm that serves mixed drinks. Be proud. Throw a party! Everyone loves watching a robot arm mix their drinks (it's true, people stand around mesmerized watching this thing every time I turn it on at the office). There are still I/O ports open on this bad boy, so it's not out of the question to add things like Neopixel rings, buzzers, or even input sensors that aren't a simple button to activate sequences. Mess around with it and see what you come up with, and show us what you've got!