File tree Expand file tree Collapse file tree 4 files changed +2
-22
lines changed Expand file tree Collapse file tree 4 files changed +2
-22
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,11 @@ Utilise un potentiomètre (potard) pour controller la position d'un servomoteur.
39
39
## Documentation
40
40
41
41
- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
42
- - Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js
43
42
44
43
## Conseils
45
44
46
45
- Un potard est un autre cas d'utilisation de l'objet 'Sensor'...
47
46
- Un potard a produit des valeurs dans une plage allant de 0 a 1023.
48
47
- Un servomoteur peut généralement étre orienté dans un angle de 0 a 180°.
49
- - ` five.Fn.map ` peut étre utiliser pour normaliser les valeur du potard (0 - 1023) en angles pour le servomoteur (0 - 179).
50
48
51
- * * *
49
+ * * *
Original file line number Diff line number Diff line change @@ -40,13 +40,11 @@ GND o---.------/\/\/------.
40
40
## ドキュメント
41
41
42
42
- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
43
- - Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js
44
43
45
44
## ヒント
46
45
47
46
- ポテンショメータは、センサーオブジェクトの別のユースケースです。
48
47
- 0〜1023の間の入力値を生成します。
49
48
- サーボは通常0〜179度の角度を動くことができます。
50
- - ` five.Fn.mapメソッド ` はポテンショメータの値(0~ 1023)をサーボの角度(0~ 179)にマッピングすることができます。
51
49
52
50
---
Original file line number Diff line number Diff line change @@ -40,13 +40,11 @@ GND o---.------/\/\/------.
40
40
## Docs
41
41
42
42
- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
43
- - Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js
44
43
45
44
## Hints
46
45
47
46
- A potentiometer is another use case for the Sensor object...
48
47
- A pot produces input values between 0 and 1023.
49
48
- A servo can typically be moved between 0 and 179 degrees.
50
- - ` five.Fn.map ` can map the pot values (0 - 1023) to servo angles (0 - 179).
51
49
52
50
---
Original file line number Diff line number Diff line change @@ -5,21 +5,7 @@ board.on('ready', function () {
5
5
var servo = new five . Servo ( 9 )
6
6
var pot = new five . Sensor ( 'A2' )
7
7
8
- pot . on ( 'change' , function ( ) {
9
- var position = five . Fn . map ( this . value ,
10
- 0 , 1023 ,
11
- 0 , 179
12
- )
13
-
14
- servo . to ( position )
15
- } )
16
-
17
- // Alternatively, sensor provides a `scale` method as an alias to Fn.map
18
- /*
19
- pot.scale(0, 179).on('change', function () {
20
-
21
- // `this.value` will reflect a scaling from 0-1023 to 0-179
8
+ pot . scaleTo ( 0 , 179 ) . on ( 'change' , function ( ) {
22
9
servo . to ( this . value )
23
10
} )
24
- */
25
11
} )
You can’t perform that action at this time.
0 commit comments