Skip to content

Commit 0e96a45

Browse files
committed
encourage to use sensor.scaleTo instead Fn.map
1 parent ffb7288 commit 0e96a45

File tree

4 files changed

+2
-22
lines changed

4 files changed

+2
-22
lines changed

exercises/robot_arm/problem.fr.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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+
* * *

exercises/robot_arm/problem.ja.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff 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
---

exercises/robot_arm/problem.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff 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
---

exercises/robot_arm/solution/solution.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,7 @@ board.on('ready', function () {
55
var servo = new five.Servo(9)
66
var pot = new five.Sensor('A2')
77

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 () {
229
servo.to(this.value)
2310
})
24-
*/
2511
})

0 commit comments

Comments
 (0)