Permalink
Browse files

Arduino.js and a start of the local server

  • Loading branch information...
1 parent 09c44da commit 2e3a26efb57621c4e43a584d520b1455b915cfd5 @reconbot committed Feb 17, 2013
Showing with 51 additions and 5 deletions.
  1. +1 −0 .gitignore
  2. +27 −5 arduino.js
  3. +19 −0 package.json
  4. +4 −0 server.js
View
@@ -0,0 +1 @@
+node_modules
View
@@ -2,10 +2,9 @@
var five = require('johnny-five');
var board = new five.Board();
-var openDoor = function () {};
+var openDoor, buildStatus;
var goDoor = function () {
-
var servo = new five.Servo({
pin: 10,
range: [120, 180],
@@ -14,7 +13,7 @@ var goDoor = function () {
openDoor = function () {
servo.min();
- setTimeout(this.max.bind(servo), 700);
+ setTimeout(servo.max.bind(servo), 700);
};
board.repl.inject({
@@ -23,9 +22,32 @@ var goDoor = function () {
};
+var goStatus = function () {
+ var green = new five.Led(5);
+ var red = new five.Led(5);
+ var onVal = 100;
+
+ buildStatus = function (good) {
+ if (good) {
+ green.brightness(onVal);
+ red.off();
+ } else {
+ green.off();
+ red.brightness(onVal);
+ }
+ };
+
+};
+
board.on("ready", goDoor);
+board.on("ready", goStatus);
+
-// var bigLed = new five.Led(6);
module.exports = {
- openDoor: openDoor
+ openDoor: function () {
+ openDoor && openDoor();
+ },
+ buildStatus: function (value) {
+ buildStatus && buildStatus(value);
+ }
};
View
@@ -0,0 +1,19 @@
+{
+ "name": "doorbell",
+ "version": "0.0.1",
+ "description": "buzzes my front door",
+ "main": "server.js",
+ "dependencies": {
+ "connect": "~2.7.2",
+ "johnny-five": "git+ssh://git@github.com:rwldrn/johnny-five.git"
+ },
+ "devDependencies": {},
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "start": "node server.js"
+ },
+ "repository": "",
+ "author": "reconbot",
+ "license": "BSD",
+ "gitHead": "09c44dab79671e6117a98447de22720e7be7a4b7"
+}
View
@@ -0,0 +1,4 @@
+/*global require:true */
+var arduino = require('./arduino');
+// arduino.openDoor();
+// arduino.buildStatus(false);

0 comments on commit 2e3a26e

Please sign in to comment.