Introduction: Build a Gesture Controlled Robot

In this Instructable we build an Arcbotics Sparki robot that can be controlled with 3D gestures. Nice feature of this project is that no additional device such as a smartphone or glove is needed to control the robot. Just move your hand over the electrode (95 x 60mm sensitive area). A MGC3130 Hillstar Development Kit from Microchip is used for the 3D gesture input sensing systems.

Step 1: Components Required

  1. Arcbotics Sparki, Arduino based robot. Other Arduino based robots will work as well.

  2. MGC3130 Hillstar Development Kit from Microchip, other 3D gesture boards, such as the Hover original or the Hover 2.0 From Hover Labs, or the Flick! should also work.

  3. A few Knex parts (not as much as in the picture)

  4. Duct tape

  5. Jumper wires

Step 2: Assembly

The Hillstar 3D gesture kit consists of three boards:

  1. The MGC3130 Module. this is the main Hillstar gesture control unit, it interfaces on one side to an electrode, and on the other side to power and a I2C interface.
  2. A four layer reference electrode with a 85x60mm sensitive area, on the bottom of this plate is a connector to connect the MGC3130 board.
  3. An I2C to USB bridge board. With this board the MGC3130 module can easily be connected to a PC with USB.

The I2C to USB bridge board is not needed, as we connect the I2C of the MGC3130 Module directly to the Robot IO ports, as shown in the schematic diagram above.

A small Knex trolly was made to support the reference electrode board. The board is attached to the trolley with some duct tape, and the completed trolley is attached to the robot with a Ty-wrap. Finally the MGC3130 Module is connected to the robot IO ports with the jumper wires.

Step 3: Code

The software is based on the Hover library from Hover Labs and can be found on Github (https://github.com/jspark311/hover_arduino).

Below is the Arduino sketch which can be downloaded to the Sparki.

There is a specific Sparki IDE available, called SparkiDuino, but I prefer to use just the standard Arduino IDE and Install the Sparki Arduino library, which can be downloaded from the downloads page: http://arcbotics.com/downloads It's not as easy as SparkiDuino, and it doesn't come with it's own driver installer (the Sparki driver installer is also on the downloads page), but it uses all the same examples and library code and it's easier in combination with other libraries, like Hover in this case.

#include <Sparki.h> // include the sparki library
#include <Wire.h> 
#include <Hover.h>

// Pin declarations for Hover
int ts = 0;
int reset = 1;

Hover hover = Hover();
byte event;
String output_string = "";
bool driving_forward = false;

void setup() {
  delay(4000);
  sparki.clearLCD();
  sparki.println("Initializing Hover...please wait.");
  sparki.updateLCD();
  hover.begin(ts, reset);
  sparki.clearLCD();
  sparki.println("Ready for Gestures!.");
  sparki.updateLCD();
}

void loop(void) {

  // Check if Hover is ready to send gesture or touch events
  if (hover.getStatus(ts) == 0) {
   
    //Get the event over i2c and print it
    event = hover.getEvent();
     
    //This section can be commented out if you don't want to see the event in text format
    output_string = hover.getEventString(event);
    if (output_string != ""){
      sparki.print(event);
      sparki.println(" = " + output_string);
      sparki.updateLCD();
    }

    switch(event)
    {
      case 40:
        driving_forward = true;
        break;
      case 80:
        sparki.moveBackward();
        break;
      case 36:
        sparki.moveLeft();
        delay(500);
        sparki.moveStop();
        break;
      case 34:
        sparki.moveRight();
        delay(500);
        sparki.moveStop();
        break;
      case 72:
        sparki.gripperOpen();
        break;
      case 66:
        sparki.gripperClose();
        break;
      case 68:
        sparki.servo(80);
        break;
      case 65:
        sparki.servo(-80);
        break;
      case 48:
        driving_forward = false;
        sparki.gripperStop();
        sparki.servo(0);
        break;
    }
   
    if (driving_forward) {
        sparki.moveForward();
    } else {
        sparki.moveStop();
    }
   
    //Reset Hover for next event
    hover.setRelease(ts);
  }
}

Step 4: Enjoy

List of commands:

  • Swipe up - drive forward
  • Swipe back - stop all movements
  • Swipe left - turn left
  • Swipe right - turn right
  • Tap top - rotate sensor 90 degrees cw
  • Tap bottom - rotate sensor 90 degrees ccw
  • Tap left - close gripper
  • Tap right - open gripper