Minim & Leap

Screen Shot 2014-05-07 at 1.05.36 AM


This is super late (sorry Dan!) but here’s a stupid pet trick. Although this doesn’t involve the Arduino, it does involve the LeapMotion. I had originally wanted to include the Leap in my final project, but didn’t have the time to actually play around with it and figure out the environment.

This is a mashup/side project with my other minim post — I think that the Leap would be fun to use with music-based applications. It only draws when your fingers can be detected – if they’re not over the Leap, then it stops drawing. It draws either an ellipse (if your touch mode is ‘touching’) or a rectangle (if your touch mode is ‘hovering’). Modes are also printed in console so you know what’s happening. (It’s much harder to get ellipses drawn…maybe I just have very shaky hands.)

My iMovie isn’t working at the moment, so this video doesn’t have audio…but the song that is playing is “Salty Sweet” by Ms Mr.

Until I get that fixed, here’s a temporary, but very short Instagram video of it (with sound).

//importing leapmotion library
import de.voidplus.leapmotion.*;

//importing minim and serial libraries
import ddf.minim.*;
import processing.serial.*;

//for music
Minim minim; 
AudioPlayer player; 

//for the leapmotion
LeapMotion leap;

float y = 0; 
float x = 0; 

void setup() {
  size(800, 500, P3D);

  leap = new LeapMotion(this);

  //start minim with this
  minim = new Minim (this);

  player = minim.loadFile ("SaltySweet.mp3"); ( );

void draw() {
  float n = noise(x);
  float t = noise(y);

  for (Hand hand : leap.getHands()) {
    for (Finger finger : hand.getFingers()) {
      // finger.draw();

      int finger_id = finger.getId();
      // Touch Emulation
      int     touch_zone        = finger.getTouchZone();
      float   touch_distance    = finger.getTouchDistance();

      switch(touch_zone) {
      case -1: // None

      case 0: // Hovering
        println("Hovering (#"+finger_id+"): "+touch_distance);

        stroke(30, 15, 77, 20);
        fill (60, 170, 205, t*4);
        rect(t*(width)-50, n*height+10, 50*n, height/2*n);

      case 1: // Touching
        println("Touching (#"+finger_id+")");

        stroke(70, 3, 11, 20);
        fill (60, 170, 205, t*4);
        ellipse(n*height+20, t*(width)-100, height/4*n, 10*n);


Leave a Reply