-
-
Save rwaldron/1604360 to your computer and use it in GitHub Desktop.
node-serialport + arduino + popcorn.js DIY video scrubber
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
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script> | |
<script src="http://burritopizza.local/socket.io/socket.io.js"></script> | |
<script src="https://gist.github.com/raw/952547/f298c7e30d0978da0c78df0ff79436e883efbad2/gistfile1.txt"></script> | |
<script src="http://popcornjs.org/code/players/youtube/popcorn.youtube.js"></script> | |
<style type='text/css'> | |
body { | |
} | |
</style> | |
<script type='text/javascript'> | |
$(function() { | |
var monkeyGoat = "http://www.youtube.com/watch?v=T0LYbP3uwNU"; | |
p = Popcorn( | |
Popcorn.youtube('monkeyGoat', monkeyGoat) | |
) | |
p.play(); | |
var queued = false; | |
function queueChange(position) { | |
if ( position < 400 && position > 160 ) { | |
return; | |
} | |
if (!queued) { | |
setTimeout(function() { | |
if (position < 300) { | |
p.currentTime(p.currentTime() - 10); | |
console.log("BACK", position) | |
} else { | |
p.currentTime(p.currentTime() + 10); | |
console.log("FORWARD", position) | |
} | |
queued = false; | |
}, 100) | |
queued = true; | |
} | |
} | |
var socket = new io.Socket("burritopizza.local"); | |
socket.connect(); | |
socket.on('connect', function(){ console.log('connect!') }) | |
socket.on('message', function(m){ | |
// jsfxgui.doIt(m) | |
queueChange(m); | |
}) | |
socket.on('disconnect', function(){ console.log('disconnect!') }) | |
}) | |
</script> | |
</head> | |
<body> | |
<h2>Soft Potentiometer + Arduino + Node.js + Socket.io + Popcorn.js + A Monkey Riding a Damn Goat = </h2> | |
<div id="monkeyGoat" style="width: 800px; height: 600px"></div> | |
<h1>AWESOME</h1> | |
</body> | |
</html> |
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
int sensorPin = A0; // select the input pin for the potentiometer | |
int sensorValue = 0; // variable to store the value coming from the sensor | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
// read the value from the sensor: | |
sensorValue = analogRead(sensorPin); | |
Serial.print(sensorValue); | |
delay(1); | |
} |
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 sys = require("sys"), | |
repl = require("repl"), | |
serialPort = require("serialport").SerialPort, | |
// Required | |
defaults = { | |
baudrate: 9600 | |
} | |
var serial = new serialPort("/dev/tty.usbmodem641" , defaults); | |
serial.on( "data", function( data ) { | |
data = +data; | |
console.log(data); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment