vincent wong
Published © GPL3+

HomeBright

Brighten your home with HomeBright.

IntermediateFull instructions provided8,890
HomeBright

Things used in this project

Story

Read more

Schematics

HomeBright Sketch (bb)

HomeBright Sketch (schem)

Code

homebright-console.js

JavaScript
cylon robot which controls the LED lightings
node homebright-console.js
"use strict";

var cylon = require("cylon");

cylon.robot({
  connections: {
    leapmotion: { adaptor: "leapmotion" },
    arduino: { adaptor: "firmata", port: "COM7" }
  },

  devices: {
    leapmotion: { driver: 'leapmotion' },
    livingroom: { driver: "led", pin: 6, connection: "arduino" },
    dininghall: { driver: "led", pin: 9, connection: "arduino" },
    bedroom: { driver: "led", pin: 10, connection: "arduino" },
    studyroom: { driver: "led", pin: 11, connection: "arduino" }
  },

  work: function(my) {
    my.leapmotion.on("hand", function(hand) {
			
			var on = hand.grabStrength > 0.5 ? false : true;
			var x = hand.palmPosition[0];
			var z = hand.palmPosition[2];

			var value = 0;
			
			if (on) {
				value = hand.palmPosition[1];
			}
			
			console.log(value);
			
			if(x > 0 &&  z > 0) {   // living room
					my.livingroom.brightness(value);
					//my.livingroom.turnOn();
			} else if (x > 0 && z < 0) {   // dining hall
					my.dininghall.brightness(value);
			} else if (x < 0 && z > 0) {   // study room
					my.studyroom.brightness(value);
			} else {   // bedroom
					my.bedroom.brightness(value);
			}

    });
  }
}).start();

package.json

JavaScript
node package config file
npm install
{
  "name": "homebright-console",
  "version": "1.0.0",
  "dependencies": {
    "cylon": "1.2.0",
    "cylon-gpio": "0.27.0",
    "cylon-i2c": "0.23.0",
    "cylon-leapmotion": "0.20.0",
    "serialport": "1.7.4",
	"firmata": "0.5.5",
    "cylon-firmata": "0.23.0"
  }
}

Credits

vincent wong

vincent wong

63 projects • 173 followers

Comments