Created
March 17, 2016 19:17
-
-
Save rwaldron/b4eb8e0fdf31db7a78dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var five = require("johnny-five"); | |
| var Particle = require("particle-io"); | |
| var app = require("express")(); | |
| var http = require("http").Server(app); | |
| var io = require("socket.io")(http); | |
| app.get("/", function(req, res) { | |
| res.sendFile(__dirname + "/index.html"); | |
| }); | |
| var board = new five.Board({ | |
| io: new Particle({ | |
| token: process.env.VIBRATOR_TOKEN, | |
| deviceId: process.env.VIBRATOR_DEVICE_ID | |
| }) | |
| }); | |
| board.on("ready", function() { | |
| var vibe = new five.Motor({ | |
| pins: { pwm: "D0", dir: "D2" } | |
| }); | |
| io.on("connection", function(socket) { | |
| socket.on("instruction", function(data) { | |
| vibe[data.command](data.speed); | |
| }); | |
| }); | |
| http.listen(3000, function() { | |
| console.log("http://localhost:3000"); | |
| }); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
