Created
February 23, 2011 04:58
-
-
Save jgautier/840042 to your computer and use it in GitHub Desktop.
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
SerialPort = require('serialport').SerialPort |
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
SerialPort = require('../deps/node-serialport/serialport').SerialPort |
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
<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> |
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
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