Last active
December 30, 2015 01:59
-
-
Save rwaldron/7760147 to your computer and use it in GitHub Desktop.
Johnny-Five compared to Cylon: Analog Sensor
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
Cylon = require '../..' | |
Cylon.robot | |
connection: | |
name: 'arduino' | |
adaptor: 'firmata' | |
port: '/dev/ttyACM0' | |
device: | |
name: 'sensor' | |
driver: 'analogSensor' | |
pin: 0 | |
upperLimit: 900 | |
lowerLimit: 100 | |
work: (my) -> | |
my.sensor.on 'upperLimit', (val) -> | |
Logger.info "Upper limit reached ===> #{val}" | |
my.sensor.on 'lowerLimit', (val) -> | |
Logger.info "Lower limit reached ===> #{val}" | |
.start() |
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 Cylon = require('../..'); | |
Cylon.robot({ | |
connection: { | |
name: 'arduino', | |
adaptor: 'firmata', | |
port: '/dev/ttyACM0' | |
}, | |
device: { | |
name: 'sensor', | |
driver: 'analogSensor', | |
pin: 0, | |
upperLimit: 900, | |
lowerLimit: 100 | |
}, | |
work: function(my) { | |
my.sensor.on('upperLimit', function(val) { | |
Logger.info("Upper limit reached ===> " + val); | |
}); | |
my.sensor.on('lowerLimit', function(val) { | |
Logger.info("Lower limit reached ===> " + val); | |
}); | |
} | |
}).start(); |
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 five = require("johnny-five"); | |
(new five.Board()).on("ready", function() { | |
var sensor = new five.Sensor({ pin: "A0", limit: [100, 900]); | |
sensor.on("limit", function(err, data) { | |
console.log("%s limit reached ===> %d", data.boundary, data.value); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment