Created
June 10, 2016 19:29
-
-
Save rondagdag/3222de5bc8439ff7b6c4d1668421875b to your computer and use it in GitHub Desktop.
tessel 2 with Adafruit RGB TCS34725 sensor publishing data using socket.io
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 tessel = require('tessel'); | |
var rgbLib = require('rgb-tcs34725'); | |
var rgb = rgbLib.use(tessel.port.A); | |
var server = require('http').createServer(); | |
var io = require('socket.io')(server); | |
io.on('connection', function(socket){ | |
console.log('new connection'); | |
socket.on('event', function(data){}); | |
socket.on('disconnect', function(){}); | |
}); | |
server.listen(3000); | |
rgb.on('ready', function() { | |
setInterval(function() { | |
rgb.getRawData(function(err, colors) { | |
if (err) throw err; | |
console.log('RED:', colors.red); | |
console.log('GREEN:', colors.green); | |
console.log('BLUE:', colors.blue); | |
console.log('CLEAR:', colors.clear); | |
io.emit('colors', colors); | |
}) | |
}, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment