# Encoder Input to select a value 0 to 10,000

**URL:** <https://discourse.nodered.org/t/encoder-input-to-select-a-value-0-to-10-000/32163>\
**Category:** General\
**Created:** [28 August 2020 16:08 UTC](https://discourse.nodered.org/t/encoder-input-to-select-a-value-0-to-10-000/32163 "2020-08-28T16:08:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Graham](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/graham/32/27867_2.png) [@Graham](https://discourse.nodered.org/u/Graham)\
**Post date:** [28 August 2020 16:08 UTC](https://discourse.nodered.org/t/encoder-input-to-select-a-value-0-to-10-000/32163/1 "2020-08-28T16:08:07Z")

</div>

This will, with a bit of luck, be the first post of many. I have started a project that is way in excess of my capabilities! The end goal is to create a control panel for the control of some industrial equipment. My plan is to build the outline of the control system by using Node-Red; I will heavily rely on this community in order to do so. Once I have a rough system working the plan will be to seek the help of a "professional" to "write it properly" using my project as a rough guide...

So one of my first hurdles is to maximize the use of an encoder. I would like the push button part of the encoder to select/scroll through a variety of parameters such as Velocity, Acceleration and Deceleration. By twisting the encoder I would like to generate a value between 0 and 10,000 for one parameter then push to select the value and move on to the next parameter... I have found some flows on the forum but nothing that increments, selects and then moves on.

All guidance and suggestions will be appreciated, thanks in advance.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 August 2020 16:24 UTC](https://discourse.nodered.org/t/encoder-input-to-select-a-value-0-to-10-000/32163/2 "2020-08-28T16:24:28Z")

</div>

Welcome to the forum Graham.  
Have you already got the encoder connected and data coming from it? If so then what events have you got so far(button, inc, dec etc).

---

<div class="post-metadata">

**Author:** ![Graham](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/graham/32/27867_2.png) [@Graham](https://discourse.nodered.org/u/Graham)\
**Post date:** [28 August 2020 17:03 UTC](https://discourse.nodered.org/t/encoder-input-to-select-a-value-0-to-10-000/32163/3 "2020-08-28T17:03:49Z")

</div>

Yes, I have the encoder connected and receiving a stream of 1 for every CW click and -1 for each CCW click. I am using the method below copied from:

[https://discourse.nodered.org/t/using-rotary-encoder/29775/13?u=graham](https://discourse.nodered.org/t/using-rotary-encoder/29775/13)

```auto
[{"id":"88d5b9e0.6a69d8","type":"change","z":"f6ce3d25.58cde","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"CLK","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":320,"wires":[["2cb38dd4.874a02"]]},{"id":"4dbfa867.fa67b8","type":"change","z":"f6ce3d25.58cde","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"DT","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":400,"wires":[["2cb38dd4.874a02"]]},{"id":"2cb38dd4.874a02","type":"function","z":"f6ce3d25.58cde","name":"","func":"var CLK;\n\n\nif ((msg['topic']) == 'CLK') {\n CLK = (msg['payload']);\n if (context.keys().includes('DT')) {\n if (CLK != (context.get('DT'))) {\n msg['payload'] = 1;\n } else {\n msg['payload'] = -1;\n }\n return msg;\n }\n} \n\nelse {\n context.set('DT', (msg['payload']));\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":360,"wires":[["9543b076.48206"]]},{"id":"8e3318a4.9b7e98","type":"comment","z":"f6ce3d25.58cde","name":"CLK","info":"","x":470,"y":280,"wires":[]},{"id":"a7845bc1.044ff8","type":"comment","z":"f6ce3d25.58cde","name":"DT","info":"","x":470,"y":440,"wires":[]},{"id":"fe4bcbaf.faeca8","type":"rpi-gpio in","z":"f6ce3d25.58cde","name":"","pin":"8","intype":"tri","debounce":"0","read":true,"x":290,"y":320,"wires":[["88d5b9e0.6a69d8"]]},{"id":"51e69e11.005ea","type":"rpi-gpio in","z":"f6ce3d25.58cde","name":"","pin":"7","intype":"tri","debounce":"0","read":true,"x":290,"y":400,"wires":[["4dbfa867.fa67b8"]]},{"id":"9543b076.48206","type":"debug","z":"f6ce3d25.58cde","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":360,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 August 2020 21:04 UTC](https://discourse.nodered.org/t/encoder-input-to-select-a-value-0-to-10-000/32163/4 "2020-08-28T21:04:36Z")

</div>

You won't find a flow to do exactly what you want. You will have to work out the logic and then implement it. I suggest building a bit at a time, so you could start with the logic to manage the 0:10000 up/down and showing that on the dashboard. Doing it incrementally like this will mean that you have to re-work bits as you add more features but that is a good way of learning.

---

<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:** [27 October 2020 21:04 UTC](https://discourse.nodered.org/t/encoder-input-to-select-a-value-0-to-10-000/32163/5 "2020-10-27T21:04:53Z")

</div>

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