# Reading outputs

**URL:** <https://discourse.nodered.org/t/reading-outputs/52913>\
**Category:** General\
**Created:** [28 October 2021 21:17 UTC](https://discourse.nodered.org/t/reading-outputs/52913 "2021-10-28T21:17:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebolisa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ebolisa/32/89203_2.png) [@ebolisa](https://discourse.nodered.org/u/ebolisa)\
**Post date:** [28 October 2021 21:17 UTC](https://discourse.nodered.org/t/reading-outputs/52913/1 "2021-10-28T21:17:40Z")

</div>

Hi,

I'm trying to read the outputs of a joystick, specifically the vectors x and y.

```auto
28/10/2021 23:04:02node: eeebad4a29142066
rested : msg : Object
object
payload: object
angle: object
direction: object
distance: 0
vector: object
x: 0
y: 0
topic: "rested"
socketid: "uf2ZCeo6yMHJHHDTAAAd"
_msgid: "2daacabf5c529c8c"

```

and I'm doing it with this function:

```auto
if(msg.payload){
    msg.payload = msg.payload[0][3]['x'];
}
return msg;

```

I appreciate if someone can correct me.  
TIA

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [28 October 2021 22:04 UTC](https://discourse.nodered.org/t/reading-outputs/52913/2 "2021-10-28T22:04:14Z")

</div>

There is [great documentation available](https://nodered.org/docs/user-guide/messages) which explains how this works.

---

<div class="post-metadata">

**Author:** ![ebolisa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ebolisa/32/89203_2.png) [@ebolisa](https://discourse.nodered.org/u/ebolisa)\
**Post date:** [29 October 2021 09:26 UTC](https://discourse.nodered.org/t/reading-outputs/52913/3 "2021-10-29T09:26:01Z")

</div>

Thanks, I made some improvements with the code. The joystick jumps to the right when I click on it with the cursor. Is there a way to tighten its movements?

```auto
if(msg.topic != 'rested'){
  msgY = {payload : msg.payload.vector.y};
  msgX = {payload : msg.payload.vector.x};
}
return [msgX, msgY];

```

---

<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:** [28 November 2021 09:26 UTC](https://discourse.nodered.org/t/reading-outputs/52913/4 "2021-11-28T09:26:53Z")

</div>

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