Giter Club home page Giter Club logo

leapmotion-philipshue's Introduction

Introduction

Leap Motion projects with Philips Hue lights

YouTube

YouTube: https://www.youtube.com/watch?v=ghNnTjDSs4w

Code Setup

Make sure you have nodejs and npm installed.

Make sure you have the Leap Motion SDK installed: https://developer.leapmotion.com/get-started

This is all using the V2 Desktop (and was developed on OSX Yosemite).

Install cylonjs, a robotics javascript framework. More info here: https://cylonjs.com

For more info on Leap Motion, check out: http://cylonjs.com/documentation/drivers/leapmotion/

For more info on Philips Hue, check out: http://cylonjs.com/documentation/platforms/hue/

Clone the directory: git clone https://github.com/cwalk/LeapMotion-PhilipsHue

Navigate to the directory and do an npm install and you should have cylon, cylon-leapmotion, and cylon-hue in node_modules.

Philips Hue Setup

Make sure you have your Philips Hue lights plugged in to a power source (like a lamp), and the power source is turned on. Also make sure you have set up the lights on the Philips Hue Bridge.

You will need to know the following:

  • LightID for each light you wish to connect to and control (I recommend using the mobile app when you set them up to figure this out easily)
  • IP Address of the Philips Hue Bridge
  • Philips Hue Bridge Username

It was a little tricky for me to find the username, so hopefully the links below will provide some guidance.

You will need to replace the HOSTNAME and USERNAME in each JavaScript file with your own IP Address and Bridge username in order for the code to work

General Help: https://my.meethue.com/en-us/ How to find the username: http://www.developers.meethue.com/documentation/getting-started

Usage

Run the files by using the command node filename.js

WARNING

An important warning, is that some of the code associated with using the Leap Motion + the Philips Hue lights is a little buggy. This means it might not always run the first time perfectly, so keep re-trying to get a good connection. Sometimes it will even "timeout" and you will have to run the script again.

My reasoning behind this is because there is a lot of network communication going on. Basically because the Leap Motion doesn't have it's own processor, it just sends a bunch of data to your computer. Your computer then has to send that data to the router the Bridge is connected on, through the JavaScript file. Then, the router relays that to the Bridge through a hardwired connection. Then the Bridge finally sends that info to the lights, through the Xigbee protocol. So theres a lot of "inbetweens" that are necessary to send the data from the Leap, to be interpretted by the code on your computer, to perform actions from the lights.

blink

blink.js will simply connect to 1 light, and toggle it on and off, through JavaScript.

array-blink

array-blink.js will connect to an array of lights, as many as you define, and toggle them on and off together.

bridge-state

bridge-state.js will log the entire state of the Philips Hue Bridge. I also added some additional code that will log out the state of each light connected to the Bridge, so you can see which lights are off and on.

brightness

brightness.js will take 1 light and use Pulse-width modulation on it, increasing the brightness by 5% until it reaches 100%, and then decreasing until it reaches 0%, and then repeats.

For some weird reason, whenever you change the brightness value on the hues, they change blue. I still haven't figured out why, but it's quite annoying

rgb

rgb.js takes 1 light, and turns it a random color every second.

disco

disco.js is to rgb.js as array-blink.js is to blink.js. This just takes multiple lights, and changes them each a different color.

turnAllOff

turnAllOff.js is a useful script to turn all the lights connected to the bridge off. Useful for debugging and resetting the light states.

turnAllOn

turnAllOn.js is a useful script to turn all the lights connected to the bridge on. Useful for debugging and resetting the light states.

leapBlink

leapBlink.js is the first script I wrote that allows you to turn on the Philips Hue bulbs, with Leap Motion integration. If the Leap Motion sees your hand, it will turn on the lights defined in the script. When it doesnt see your hand, the lights will turn off.

Be warned, the Leap sends so much data, that it sometimes breaks, as the Philips Hue are connected on a network as explained above. Simply kill the script, run turnAllOff.js and try to re-run if you have issues

leapGestureBlink

leapGestureBlink.js has a couple different uses, but it's main use is to use recognizes gestures from the Leap Motion to do different things with the Philips Hue Lights.

Supported Gestures:

  • swipe: Swiping your hand across the Leap Motion will change the brightness of the Hue bulb. The brightness value is derived from how high on the Y axis your hand is in relation to the Leap Motion.
  • keyTap: This will change the color of the Hue bulb to a random color, like rgb.js, each time a new gesture is recognized.
  • screenTap: same as keyTap.

leapBlink-SeparateRobots

leapBlink-SeparateRobots.js is a modification of leapGestureBlink.js and is still pretty buggy. There are 3 flags on top, and only 1 can be used at a time. So change whichever function you wish to use to true and leave the other 2 false.

  • adjustRGB: This will allow you to change the color of the Hue bulb based on where your hand is in the X axis as interpretted by the Leap Motion.
  • adjustBrightness: This will allow you to change the brightness of the Hue bulb based on where your hand is in the Y axis as interpretted by the Leap Motion.
  • gestureControl: Very similar to leapGestureBlink.js

leapCircle

leapCircle.js is my personal favorite program written for interaction between the Leap Motion and the Philips Hue.

In this program, I set the lights up around the room in a circle. I then programmed to turn on a specific light if my hand was in that area of space over the Leap Motion. So if the light was directly in front of me, I programmed it so when my hand is directly in front of the Leap Motion, only that light would turn on.

The lights were placed around the room in a circle, so I basically had a control set up like in the diagram below. Where I could move my hand in a giant circle over the Leap to turn on all the lights in the room, in a sort of magical effect. You can also point at individual lights, and they should turn on (because your hand is over the leap in the same direction the light is placed in the room).

When your hand exits the view of the Leap, all the lights will turn off.

![Leap Circle Diagram](/Leap Circle.jpg?raw=true "Leap Circle Diagram")

leapmotion-philipshue's People

Contributors

cwalk avatar walkc120 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

antonynasce-uh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.