-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
52 lines (46 loc) · 1.53 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
var accelerometer = new five.Accelerometer({
controller: "ADXL345"
});
var tempInternal = new five.Thermometer({
controller: "LM35",
pin: "A1"
});
var multi = new five.Multi({
controller: "BMP280"
});
accelerometer.on("change", function() {
console.log("accelerometer");
console.log(" x :", this.x);
console.log(" y :", this.y);
console.log(" z :", this.z);
console.log(" pitch: :", this.pitch);
console.log(" roll: :", this.roll);
console.log(" acceleration :", this.acceleration);
console.log(" inclanation :", this.inclination);
console.log(" orientation :", this.orientation);
console.log("---------------------------------------");
});
tempInternal.on("change", function() {
console.log("Internal tempature")
console.log(" Celsius : ", this.celsius);
console.log(" Fahrenheit : ", this.fahrenheit);
console.log("---------------------------------------");
})
multi.on("change", function() {
console.log("Thermometer");
console.log(" Celsius :", this.thermometer.celsius);
console.log(" Fahrenheit :", this.thermometer.fahrenheit);
console.log(" Kelvin :", this.thermometer.kelvin);
console.log("");
console.log("Barmoeter")
console.log(" Pressure :", this.barometer.pressure);
console.log("");
console.log("Altimeter")
console.log(" Feet :", this.altimeter.feet);
console.log(" Meters :", this.altimeter.meters);
console.log("----------------------------------------");
});
});