Skip to content

Instantly share code, notes, and snippets.

@jmontross
Created March 1, 2013 23:00
Show Gist options
  • Save jmontross/5068637 to your computer and use it in GitHub Desktop.
Save jmontross/5068637 to your computer and use it in GitHub Desktop.
node_arduino
// var arduino = require("johnny-five")
// , board = new arduino.Board();
// /*, photo = require('./photo')
// , sendgrid = require)''
// */
// board.on("ready", function(){
// var button = new arduino.Button(7);
// // button.on
// board.repl.inject({
// button: button
// });
// button.on("up", function() {
// console.log("Button Pressed");
// });
// });
// PostCode = require('./email.js')
var querystring = require('querystring');
var http = require('http');
var fs = require('fs');
function PostCode(message) {
// Build the post string from an object
var post_data = querystring.stringify({
'message' : message
});
// An object of options to indicate where to post to
var post_options = {
host: 'colinandlaurenwedding.heroku.com',
port: '80',
path: '/mail',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': post_data.length
}
};
// Set up the request
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
post_req.write(post_data);
post_req.end();
}
var querystring = require('querystring');
var http = require('http');
var fs = require('fs');
function PostCode(message) {
// Build the post string from an object
var post_data = querystring.stringify({
'message' : message
});
// An object of options to indicate where to post to
var post_options = {
host: 'colinandlaurenwedding.heroku.com',
port: '80',
path: '/mail',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': post_data.length
}
};
// Set up the request
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
// post the data
post_req.write(post_data);
post_req.end();
}
var five = require("johnny-five")
, board = new five.Board();
board.on("ready", function() {
var button = new five.Button(7);
var light = (new five.Led(2))
light.off();
var lightOn = false;
board.repl.inject({
button: button
});
button.on("up", function() {
if(lightOn){
light.off();
console.log('light off');
lightOn = false;
PostCode("light is off")
}
else {
light.on();
console.log('light on');
lightOn = true;
PostCode("light is on");
}
console.log("Button Pressed");
});
});
/*
# could connect to a raspberry pi -> hdmi out, sd card, usb, wifi-usb ease.
# fermata -> has its own way of sending output to
# can use processing -> language on c.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment