# 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:** 1
**Showing post:** 3

<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":[]}]

```

---

_[View the full topic](https://discourse.nodered.org/t/encoder-input-to-select-a-value-0-to-10-000/32163)._
