# Dim or brighten gradually while pressing button? Lerp problem?

**URL:** <https://discourse.nodered.org/t/dim-or-brighten-gradually-while-pressing-button-lerp-problem/17068>\
**Category:** General\
**Created:** [24 October 2019 01:53 UTC](https://discourse.nodered.org/t/dim-or-brighten-gradually-while-pressing-button-lerp-problem/17068 "2019-10-24T01:53:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yamlCase](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yamlcase/32/13436_2.png) [@yamlCase](https://discourse.nodered.org/u/yamlCase)\
**Post date:** [24 October 2019 01:53 UTC](https://discourse.nodered.org/t/dim-or-brighten-gradually-while-pressing-button-lerp-problem/17068/1 "2019-10-24T01:53:28Z")

</div>

Is there a simple solution to gradually increase the brightness of a light while holding a button, and stop dimming as soon as I release? I'm harkening back to my game dev days where we'd do this with linear interpolation. I'm hoping someone has a node or flow out there that'll handle all the maths so I don't have to reinvent the wheel. Thanks!

Home Assistant user.

---

<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:** [24 October 2019 04:39 UTC](https://discourse.nodered.org/t/dim-or-brighten-gradually-while-pressing-button-lerp-problem/17068/2 "2019-10-24T04:39:25Z")

</div>

The ['easing' node](https://flows.nodered.org/node/node-red-contrib-easing) might help you with this.  
Do you get payloads while holding the button ?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [24 October 2019 08:27 UTC](https://discourse.nodered.org/t/dim-or-brighten-gradually-while-pressing-button-lerp-problem/17068/3 "2019-10-24T08:27:52Z")

</div>

You should perhaps also note that LED mains-powered lights are notoriously difficult to dim smoothly. So maybe don't assume that any stepping is being caused by your app.

---

<div class="post-metadata">

**Author:** ![yamlCase](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yamlcase/32/13436_2.png) [@yamlCase](https://discourse.nodered.org/u/yamlCase)\
**Post date:** [26 October 2019 19:24 UTC](https://discourse.nodered.org/t/dim-or-brighten-gradually-while-pressing-button-lerp-problem/17068/4 "2019-10-26T19:24:21Z")

</div>

The easing node actually is a great solution. I'm combining this with Mat's Tradfri tutorial for something I hope to be pretty awesome.
