Skip to content

Compare: Sensor

New page
Showing with 474 additions and 65 deletions.
  1. +1 −1 Accelerometer.md
  2. +5 −12 Board.md
  3. +1 −0 Button.md
  4. +160 −0 Fn.md
  5. +34 −23 GPS.md
  6. +2 −2 Getting-Started-with-Johnny-Five-and-HC-05-Bluetooth-Serial-Port-Module.md
  7. +58 −8 Getting-Started.md
  8. +1 −0 HC-05-datasheet-and-AT-commands.md
  9. +2 −3 Home.md
  10. +65 −2 Hygrometer.md
  11. +1 −1 Led.Digits.md
  12. +1 −5 Led.md
  13. +64 −2 Multi.md
  14. +1 −1 Piezo.md
  15. +2 −1 Related-Libararies.md
  16. +6 −0 Sensor.md
  17. +1 −1 ShiftRegister.md
  18. +69 −3 Thermometer.md
6 changes: 6 additions & 0 deletions Sensor.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The `Sensor` class constructs objects that represent a single analog sensor comp
| pin | Number, String | Analog Pin. The Number or String address of the pin the sensor is attached to, ie. “A0” or “I1” | | yes |
| freq | Number | Milliseconds. The frequency in ms of data events. | 25ms | no |
| threshold | Number | Any. The change threshold (+/- value). | 1 | no |
| enabled | boolean | Whether to start emitting events right away (>= [v0.9.12](https://github.com/rwaldron/johnny-five/releases/tag/0.9.12)) | `true` | no |
</span>

- **options (experimental)** These options can be used with the `Sensor` class, but are considered experimental.
Expand All @@ -45,6 +46,7 @@ The `Sensor` class constructs objects that represent a single analog sensor comp
| `analog` | ADC reading _scaled_ to 8 bit values (0-255). | Yes |
| `constrained` | ADC reading _constrained_ to 8 bit values (0-255). | Yes |
| `value` | ADC reading, scaled. | Yes |
| `freq` | The rate in milliseconds to emit the data event. Disables the event if set to `null`. (>= [v0.9.12](https://github.com/rwaldron/johnny-five/releases/tag/v0.9.12)) | No |

## Component Initialization

Expand Down Expand Up @@ -227,6 +229,10 @@ board.on("ready", () => {
});
```

- **enable()** Start emitting "data" and "change" events, at a rate determined by the user defined `freq` in milliseconds. No-op if Sensor is already enabled. (>= [v0.9.12](https://github.com/rwaldron/johnny-five/releases/tag/v0.9.12))

- **disable()** Stop emitting "data" and "change" events. No-op if Sensor is already disabled. (>= [v0.9.12](https://github.com/rwaldron/johnny-five/releases/tag/v0.9.12))

## Events

- **change** The "change" event is emitted whenever the value of the sensor changes more than the threshold value allows.
Expand Down