Introduction: Controlling Arduino Car Via Leap Motion
Last time, I created an Arduino Car, which is controlled via Web. This time, I have used the same car but it’s controlled via Leap Motion.
Step 1: What Is Leap Motion.
You can check what “Leap Motion” is by visiting the official website.
The device uses infrared light in order to measure various information like positioning, angle and hand and finger gestures. The picture above is taken from the visualizer of Leap Motion. The accuracy of the device is 1/100 mm – So I would say it has quite high accuracy.
Step 2: System Architecture, Components and Software Libraries.
The system architecture of this prototype is drawn above. The last time, I used Web to control the car but this time I have used Leap Motion. The other parts are the same.
Here are the components and software libraries for the project.
- Arduino Uno x 1
- XBee Shield (sparkfun) x 1
- XBee Explorer USB(sparkfun) x 1
- XBee (Series 1) x 2
- Motor Driver TA7267BP x 2
- Capacitor 0.1uF x 2, 33uF x 2
- Tamiya Double GearBox
- Tamiya Universal Plate
- Tamiya Off-road Tire Set.
- Tamiya Ball caster
- Battery Box (for motor power)
- Mobile Battery (for Arduino power)
- Node.js (for XBee control and Web Server)
- node-serialport (a library of Node.js to handle serial connection)
- Socket.IO (for Web Screen Control)
Step 3: Breadboard Wiring Diagram.
There is no difference in the Wiring diagram.
Step 4: Specification for Controlling the Car Via Leap Motion
You can download the source codes of this project at GitHub.
The Leap Motion library provides hand information of 200-300 times in a second. It’s too much for this project. So I used the information every 5 times.
The device has a 3D coordinate system as shown above (the picture is taken from the official website).
In the current project I designed the following specifications for controlling the Arduino car.
These two rules are top priority.
- If the device detects no hands it will stop.
- If the device detects a number of fingers less than two it will stop.
The positioning of the hands determines the car's movement.
- If the X-axis absolute value is less than 10 cm and the Z-axis absolute value is less than 5 cm, it will stop.
- A check on the X-axis and Z-axis absolute value comparison is to be performed. Whichever axis has larger value will be used in such a case. The car can move only in one direction (left rotation, right rotation, forward or backward/reverse) at a time.
- If the Z-axis is of negative value, the car will move Backward/Reverse. If the Z-axis is of positive value, the car will move Forward.
- If the X-axis is of negative value, the car will move Left. If the X-axis is of positive value, the car will move Right.
- The value of the Y-axis determines the power of the motor. A higher value will lead to more power.
The actual accuracy of the device relies on the distance between the device and the hand position. For safety purposes, I would program the car to stop when the device finds either no hand or inadequate data.
The direction based on this rules will be transmitted simultaneously to the Arduino car via XBee and to Web via Socket.IO. I can figure out the kind of direction transmitted to the car by checking Web browser.
It took some time to adjust the specification. Understanding the Leap Motion library and tune-up for deciding the specification is the key part of this project.
Step 5: Conclusion
I used Leap Motion to control the car in the current project, stepping up from the former web-based project. When using Leap Motion, you may suffer hand fatigue in a short time. I think the posture of using the device is unnatural for us. That may be the difficulties of using Leap Motion for a long time.
Leap Motion provides libraries and useful documents for major programming languages. So if you are familiar with one of these languages, you will feel easy to use it. The cost of the device is $99.99. So I think it is a reasonable device for prototyping for makers.
We have a be nice policy.
Please be positive and constructive.