Control Leap Motion using Arduino
In this tutorial we will learn about how to control leap motion sensor with Arduino. How to use Leap motion device in our projects using Arduino and other microcontrollers. So in this post, we will learn how to “Blink LED” with hand gestures by using Leap Motion controller. How to control electronic devices with leap sensor and how many types of controllers can interface with this motion detecting device.
First of all, I will recommend you that when buying leap motion (motion detector) controller first you have to get used to it properly. So you have to know about the basic rules and specification. And get in touch with how it recognizes your hands by tracking the motions of your hands.
Here is the link for how to start with gestures recognizing technology
01: How many types of controllers that can Interface with Leap motion controller
The most common issue that arrives in users mind is that the leap motion sensor is only for playing games..? And does it only for seeing hand gestures in computers..? My answer is NO. In my point of view, This leap motion controller (motion detecting) device can have the ability to make something that you can’t even imagine.
Using this motion control sensor you can make things that can blow out the others mind. It gives you a way to connect the 3D world with real hardware world technology.
When first time I bought leap motion controller () I was confused with it. I was thinking that I wasted my money and got stuck with the hell of this device. When I downloaded this app there were only I saw the games to play. I was doing my engineering at that time so I was thinking that the app is for programming like others microcontroller (like Arduino).And I stuck there.
But then I think it was wrong!
After a lot of searching on google, I got a little information that it can control hardware’s when using with microcontrollers like Arduino and others. So I ran to my bag and take out the Arduino board. Both leap motion controller and Arduino are connected with my laptop USB ports and then I start to write a program of Arduino, Ohh it doesn’t work then again a lot of searches I found that there will be some more programming software must be used for controlling leap motion controller (motion detector) technology with Arduino.
This is also one of the reasons that I am writing a post what is Leap Motion and How its works and got a positive response from audience to motivate me to write about controlling physical devices like DC motors, Servos motors, robots, making projects with leap motion controller (3D hand gestures device) with Arduino.
So here is the list of programming software for controlling 3D technology with Arduino.
- Visual Studio.
- Unity 3D.
- Cylon.js
- Processing.
These are the software’s you can use with Arduino to control motion detector ( gestures recognizing technology ).
Here I am giving you the details about Processing software using with Arduino and leap motion.
02: Processing with Leapmotion and Arduino
Processing is the software in which we program in Java language. You can make graphics, 2D, and 3D animations and draw objects and much more.
The Knowledgeable thing is that Arduino software is made by using processing language. This the simplest language and very easy java sketch. So you don’t have to worry about its programming there are a lot of examples to start with it.
03: How to Download and getting Started with Processing Software
Go to the site of processing Link download processing software(https://processing.org/download/?processing) download it. After downloading extract it. Now you got the inside the extracted folder. Open it you got the window screen open.
Now for controlling LeapMotion (3D hand gestures technology ) and Arduino with processing, we must install libraries of leap motion controller and Arduino here below are the steps for installing libraries.
- Here click Sketch
- click Import Library
- Then click Add Library
Now you get a new window. Write leap motion in search area you will get a library of leap motion for processing click it and install it.
The same processes repeat for Arduino’s library to do this you should write Arduino in search instead of leap-motion and install the Arduino library.
Now connect Arduino and leap motion and check this video for controlling your first real world hardware with leap-motion controller and Arduino using processing software and enjoy it.The Code is below the video.
04: Code for Processing
import processing.serial.*; import de.voidplus.leapmotion.*; LeapMotion leap; Serial myPort; void setup() { leap = new LeapMotion(this); println(Serial.list()); // initializing the port //myPort = new Serial(this,Serial.list()[0], 9600); } void draw() { // background(0); // for (Hand hand : leap.getHands()) { pushMatrix(); float handSize = hand.getSphereRadius(); int handSize2 = int(handSize); myPort.write(handSize2); println(handSize2); popMatrix(); } }
05: Code for Arduino
int val; int led = 13; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by // the setup routine runs once when you press reset: void setup() { Serial.begin(9600); pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { if (Serial.available() == 'n') { // Check if there is a new message val= Serial.read(); // 1st fragment if (val<60) { digitalWrite(led,LOW); } if (val>60) { digitalWrite(led,HIGH); } }}
Hope you enjoy this lesson. I am waiting for your precious Feedback about this post.
There are more tutorials on Leap motion so Stay connected & Comment below if you have any query and Subscribe to our YouTube Channel for video Tutorials.