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.
3939## Documentation
4040
4141- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
42- - Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js
4342
4443## Conseils
4544
4645- Un potard est un autre cas d'utilisation de l'objet 'Sensor'...
4746- Un potard a produit des valeurs dans une plage allant de 0 a 1023.
4847- 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).
5048
51- * * *
49+ * * *
Original file line number Diff line number Diff line change @@ -40,13 +40,11 @@ GND o---.------/\/\/------.
4040## ドキュメント
4141
4242- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
43- - Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js
4443
4544## ヒント
4645
4746- ポテンショメータは、センサーオブジェクトの別のユースケースです。
4847- 0〜1023の間の入力値を生成します。
4948- サーボは通常0〜179度の角度を動くことができます。
50- - ` five.Fn.mapメソッド ` はポテンショメータの値(0~ 1023)をサーボの角度(0~ 179)にマッピングすることができます。
5149
5250---
Original file line number Diff line number Diff line change @@ -40,13 +40,11 @@ GND o---.------/\/\/------.
4040## Docs
4141
4242- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
43- - Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js
4443
4544## Hints
4645
4746- A potentiometer is another use case for the Sensor object...
4847- A pot produces input values between 0 and 1023.
4948- 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).
5149
5250---
Original file line number Diff line number Diff line change @@ -6,20 +6,6 @@ board.on('ready', function () {
66 var pot = new five . Sensor ( 'A2' )
77
88 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
22- servo.to(this.value)
9+ servo . to ( pot . scaleTo ( 0 , 179 ) )
2310 } )
24- */
2511} )
You can’t perform that action at this time.
0 commit comments