Skip to content

Commit

Permalink
Sensor: simplify basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Jun 23, 2015
1 parent ef44933 commit 7100750
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 88 deletions.
50 changes: 6 additions & 44 deletions docs/sensor.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,16 @@ var board = new five.Board();

board.on("ready", function() {

// Create a new `sensor` hardware instance.
var sensor = new five.Sensor({
pin: "A0",
freq: 250
});
// Create a new generic sensor instance for
// a sensor connected to an analog (ADC) pin
var sensor = new five.Sensor("A0");

// Inject the `sensor` hardware into
// the Repl instance's context;
// allows direct command line access
this.repl.inject({
sensor: sensor
// When the sensor value changes, log the value
sensor.on("change", function() {
console.log(this.value);
});

// Properties

// sensor.scaled
//
// Current value of a sensor, scaled to a value
// between the lower and upper bound set by calling
// scale( low, high ).
//
// Defaults to value between 0-255
//


// Sensor Event API

// "data"
//
// Fires when the pin is read for a value
//
sensor.scale([0, 100]).on("data", function() {
console.log(this.value, this.raw);
});

// "change"
//
// Aliases: "bend", "force", "slide", "touch"
//
// Fires when value of sensor changes
//
});

// Tutorials
//
// http://protolab.pbworks.com/w/page/19403657/TutorialSensors
// http://www.dfrobot.com/wiki/index.php?title=Analog_Slide_Position_Sensor_(SKU:_DFR0053)

```


Expand Down
50 changes: 6 additions & 44 deletions eg/sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,12 @@ var board = new five.Board();

board.on("ready", function() {

// Create a new `sensor` hardware instance.
var sensor = new five.Sensor({
pin: "A0",
freq: 250
});
// Create a new generic sensor instance for
// a sensor connected to an analog (ADC) pin
var sensor = new five.Sensor("A0");

// Inject the `sensor` hardware into
// the Repl instance's context;
// allows direct command line access
this.repl.inject({
sensor: sensor
// When the sensor value changes, log the value
sensor.on("change", function() {
console.log(this.value);
});

// Properties

// sensor.scaled
//
// Current value of a sensor, scaled to a value
// between the lower and upper bound set by calling
// scale( low, high ).
//
// Defaults to value between 0-255
//


// Sensor Event API

// "data"
//
// Fires when the pin is read for a value
//
sensor.scale([0, 100]).on("data", function() {
console.log(this.value, this.raw);
});

// "change"
//
// Aliases: "bend", "force", "slide", "touch"
//
// Fires when value of sensor changes
//
});

// Tutorials
//
// http://protolab.pbworks.com/w/page/19403657/TutorialSensors
// http://www.dfrobot.com/wiki/index.php?title=Analog_Slide_Position_Sensor_(SKU:_DFR0053)

0 comments on commit 7100750

Please sign in to comment.