-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
// Outputs "Hello World" to the console | ||
console.log("Hello World"); | ||
// https://github.com/rwaldron/johnny-five/ | ||
// Johonny Five | ||
// npm install johnny-five | ||
|
||
// Be sure to install on Arduino: File > Examples > Firmata > StandardFirmata | ||
// Connect your computer to the Arduino | ||
|
||
// Sets module to variable "five" | ||
var five = require("johnny-five"); | ||
|
||
// Attempts to find a connected device | ||
// Will fail with error if none are found | ||
var board = new five.Board(); | ||
|
||
// When device is connected... | ||
board.on("ready", function() { | ||
// Create an Led on pin 13 and strobe it on/off | ||
(new five.Led(13)).strobe(); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// This will be a combination of a socket.io and express.js server | ||
// Socket.io functions as a communication platform | ||
|
||
// Set express, application, then startup server | ||
var express = require("express"); | ||
var app = express(); | ||
|
||
// Note that this part differs from previous examples, http is separated out | ||
var http = require("http").Server(app); | ||
|
||
// include the socket.io program and run it | ||
var io = require("socket.io")(http); | ||
|
||
// Sets the /static webpage route to the /public folder | ||
app.use("/static", express.static(__dirname + "/public")); | ||
|
||
// Add a "route" that leads to the req/res, as seen in Node.js | ||
app.get("/", function(req, res){ | ||
// Grab a file and respond with that | ||
res.sendFile(__dirname + "/public/socket.html"); | ||
}); | ||
|
||
// if someone connects to socket io | ||
io.on("connection", function(socket){ | ||
console.log("a user connected"); | ||
io.emit("message", "Hello back"); | ||
}); | ||
|
||
// Starts up the server | ||
var server = http.listen(1337, function() { | ||
|
||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Example Web Page</title> | ||
</head> | ||
<body> | ||
<h1>My Webpage</h1> | ||
<p>Here it is</p> | ||
|
||
<!--- Note that /static is used, even if the picture is in /public ---> | ||
<img src="/static/makerbar.jpg" alt="Makerbar picture"> | ||
|
||
<script src="/socket.io/socket.io.js"></script> | ||
<script> | ||
var socket = io(); | ||
|
||
socket.on("message", function(msg){ | ||
console.log(msg); | ||
}); | ||
</script> | ||
</body> | ||
</html> |