Skip to content

Instantly share code, notes, and snippets.

@Resseguie
Last active August 29, 2015 14:02
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 Resseguie/1a834419d26d8545e7ea to your computer and use it in GitHub Desktop.
Save Resseguie/1a834419d26d8545e7ea to your computer and use it in GitHub Desktop.
Voodoospark #23 code
var cylon = require('cylon');
cylon.robot({
connection: {
name: 'voodoospark',
adaptor: 'voodoospark',
accessToken: process.env.SPARK_TOKEN,
deviceId: process.env.SPARK_DEVICE_ID,
module: 'spark'
},
devices: [{
name: 'led',
driver: 'led',
pin: 'D7'
}, {
name: 'sensor',
driver: 'analogSensor',
pin: 'A7'
}],
work: function(my){
var analogValue = 0;
my.led.turnOff();
every((1).second(), function(){
my.led.toggle();
analogValue = my.sensor.analogRead();
if (analogValue) {
var voltage = analogValue * (3300/1024);
var celsius = (voltage - 500) / 10;
var fahrenheit = ((celsius * 9) / 5) + 32;
console.log(Math.round(celsius) + ' celsius or ' + Math.round(fahrenheit) + ' fahrenheit');
}
});
}
}).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment