# Movement of two servos

**URL:** <https://discourse.nodered.org/t/movement-of-two-servos/79674>\
**Category:** General\
**Created:** [9 July 2023 21:01 UTC](https://discourse.nodered.org/t/movement-of-two-servos/79674 "2023-07-09T21:01:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Surfb](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@Surfb](https://discourse.nodered.org/u/Surfb)\
**Post date:** [9 July 2023 21:01 UTC](https://discourse.nodered.org/t/movement-of-two-servos/79674/1 "2023-07-09T21:01:09Z")

</div>

I want to move two servos (X and Y) from node-red with the node-red-contrib-ui-joystick and an esp32 card, through the MQTT protocol but I don't know how to make that node return numeric values, I only get the addresses like: up, down, right and left

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 July 2023 22:38 UTC](https://discourse.nodered.org/t/movement-of-two-servos/79674/2 "2023-07-09T22:38:57Z")

</div>

Here are 2 examples of mapping strings to numeric output.

```auto
[{"id":"8c79df799a065775","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"right","payloadType":"str","x":230,"y":4020,"wires":[["176f4895991e0b73","c972b7a991f0d619"]]},{"id":"176f4895991e0b73","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"right","fromt":"str","to":"1","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"left","fromt":"str","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":4040,"wires":[["a5d6577723690188"]]},{"id":"c972b7a991f0d619","type":"switch","z":"b9860b4b9de8c8da","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"left","vt":"str"},{"t":"eq","v":"right","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":310,"y":4100,"wires":[["fccde62f0a39cb30"],["e491dde00075eb15"]]},{"id":"78aae710123dc67a","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"left","payloadType":"str","x":230,"y":4060,"wires":[["176f4895991e0b73","c972b7a991f0d619"]]},{"id":"a5d6577723690188","type":"debug","z":"b9860b4b9de8c8da","name":"debug 320","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":4040,"wires":[]},{"id":"fccde62f0a39cb30","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":4080,"wires":[["bce0347d7989f9bd"]]},{"id":"e491dde00075eb15","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":4120,"wires":[["bce0347d7989f9bd"]]},{"id":"bce0347d7989f9bd","type":"debug","z":"b9860b4b9de8c8da","name":"debug 321","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":4100,"wires":[]}]

```

You could also use Javascipt in a function node or JSONata in a change node.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 September 2023 22:39 UTC](https://discourse.nodered.org/t/movement-of-two-servos/79674/3 "2023-09-07T22:39:02Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
