Skip to content

Commit

Permalink
example temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex St John committed Jan 11, 2015
1 parent 5973cb4 commit f8bddaf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Cylon-JS Sensor Examples/.DS_Store
Binary file not shown.
31 changes: 31 additions & 0 deletions Cylon-JS Sensor Examples/temperature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Plug the temperature sensor into the Analog port A0 on the provided
// Seeed Sensor Kit Arduino Shield
// MUST be in the analog pin slots!

var Cylon = require('cylon');

Cylon
.robot({ name: 'Temperature'})
.connection('edison', { adaptor: 'intel-iot' })
.device('sensor', { driver: 'analogSensor', pin: 0, connection: 'edison' })
.on('ready', function(my) {
var sensorVal = 0;
var ready = false;

my.sensor.on('analogRead', function(data) {
sensorVal = data;
console.log('Temperature Sensor Value:' + sensorVal);
});

setInterval(function() {
if (ready) {
var toSend = {
analogSensor: sensorVal
};
if (err != null) {
console.log("Error sending analog sensor information: " + err);
}
}
}, 2000);
})
.start();

0 comments on commit f8bddaf

Please sign in to comment.