/brightness.js Secret
Last active
December 26, 2015 03:22
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 raspi = require('raspi-io'); | |
var five = require('johnny-five'); | |
var board = new five.Board({ | |
io: new raspi() | |
}); | |
board.on('ready', function(){ | |
var virtual = new five.Board.Virtual( | |
new five.Expander("PCF8591") | |
); | |
var a = new five.Sensor({ | |
// PCF8591 module YL-40 | |
// A0:LDR(Light Dependent Resistor) | |
// A1:NC | |
// A2 Thermistor | |
// A3:Potentiometer | |
pin:"A0", | |
board:virtual | |
}); | |
var ubidots = require('ubidots'); | |
var client = ubidots.createClient('<Your API Key>'); | |
client.auth(function () { | |
this.getDatasources(function (err, data) { | |
console.log(data.results); | |
}); | |
// データ保存先のVariableを取得 | |
var v = this.getVariable('<Variable ID>') | |
a.on("change", function(){ | |
v.saveValue(this.value); // Variableにデータを保存 | |
console.log(this.value); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment