diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..fcce0af Binary files /dev/null and b/.DS_Store differ diff --git a/Cylon-JS Sensor Examples/.DS_Store b/Cylon-JS Sensor Examples/.DS_Store new file mode 100644 index 0000000..3f3b674 Binary files /dev/null and b/Cylon-JS Sensor Examples/.DS_Store differ diff --git a/Cylon-JS Sensor Examples/temperature.js b/Cylon-JS Sensor Examples/temperature.js new file mode 100644 index 0000000..bb3f135 --- /dev/null +++ b/Cylon-JS Sensor Examples/temperature.js @@ -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(); \ No newline at end of file