Skip to content

Instantly share code, notes, and snippets.

@jgautier
Created February 23, 2011 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgautier/840042 to your computer and use it in GitHub Desktop.
Save jgautier/840042 to your computer and use it in GitHub Desktop.
SerialPort = require('serialport').SerialPort
SerialPort = require('../deps/node-serialport/serialport').SerialPort
<html>
<head>
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script>
$(function(){
var onOff="off";
$("#onOff").click(function(){
if(onOff=="off"){
onOff="on";
}else{
onOff="off";
}
$.get("/"+onOff,function(){
});
$(this).val(onOff);
});
});
</script>
</head>
<body>
<input type="button" id="onOff" value="Off" height="3000" width="3000"></input>
</body>
</html>
var arduino = require('./deps/node-arduino/lib/arduino')
, board = arduino.connect('/dev/ttyACM0')
, express=require('express'),
app = express.createServer();
;
app.use(express.staticProvider(__dirname + '/public'));
app.get('/on', function(req, res){
//setting pin mode here because i could not get it to work when setting it up top
board.pinMode(12, arduino.OUTPUT);
board.digitalWrite(12, arduino.HIGH);
res.send("on");
});
app.get('/off',function(req,res){
//setting pin mode here because i could not get it to work when setting it up top
board.pinMode(12, arduino.OUTPUT);
board.digitalWrite(12, arduino.LOW);
res.send("off");
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment