Skip to content

Commit

Permalink
encourage to use sensor.scaleTo instead Fn.map
Browse files Browse the repository at this point in the history
  • Loading branch information
ccarruitero committed Aug 29, 2019
1 parent ffb7288 commit a6cc0ad
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 22 deletions.
4 changes: 1 addition & 3 deletions exercises/robot_arm/problem.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ Utilise un potentiomètre (potard) pour controller la position d'un servomoteur.
## Documentation

- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
- Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js

## Conseils

- Un potard est un autre cas d'utilisation de l'objet 'Sensor'...
- Un potard a produit des valeurs dans une plage allant de 0 a 1023.
- Un servomoteur peut généralement étre orienté dans un angle de 0 a 180°.
- `five.Fn.map` peut étre utiliser pour normaliser les valeur du potard (0 - 1023) en angles pour le servomoteur (0 - 179).

* * *
* * *
2 changes: 0 additions & 2 deletions exercises/robot_arm/problem.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ GND o---.------/\/\/------.
## ドキュメント

- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
- Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js

## ヒント

- ポテンショメータは、センサーオブジェクトの別のユースケースです。
- 0〜1023の間の入力値を生成します。
- サーボは通常0〜179度の角度を動くことができます。
- `five.Fn.mapメソッド`はポテンショメータの値(0~1023)をサーボの角度(0~179)にマッピングすることができます。

---
2 changes: 0 additions & 2 deletions exercises/robot_arm/problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ GND o---.------/\/\/------.
## Docs

- Sensor - https://github.com/rwaldron/johnny-five/wiki/Sensor
- Fn - https://github.com/rwaldron/johnny-five/blob/master/lib/fn.js

## Hints

- A potentiometer is another use case for the Sensor object...
- A pot produces input values between 0 and 1023.
- A servo can typically be moved between 0 and 179 degrees.
- `five.Fn.map` can map the pot values (0 - 1023) to servo angles (0 - 179).

---
16 changes: 1 addition & 15 deletions exercises/robot_arm/solution/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ board.on('ready', function () {
var pot = new five.Sensor('A2')

pot.on('change', function () {
var position = five.Fn.map(this.value,
0, 1023,
0, 179
)

servo.to(position)
})

// Alternatively, sensor provides a `scale` method as an alias to Fn.map
/*
pot.scale(0, 179).on('change', function () {
// `this.value` will reflect a scaling from 0-1023 to 0-179
servo.to(this.value)
servo.to(pot.scaleTo(0, 179))
})
*/
})

0 comments on commit a6cc0ad

Please sign in to comment.