# Neopixels: how to set msg.brightness?

**URL:** <https://discourse.nodered.org/t/neopixels-how-to-set-msg-brightness/5132>\
**Category:** General\
**Created:** [23 November 2018 06:30 UTC](https://discourse.nodered.org/t/neopixels-how-to-set-msg-brightness/5132 "2018-11-23T06:30:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [23 November 2018 06:30 UTC](https://discourse.nodered.org/t/neopixels-how-to-set-msg-brightness/5132/1 "2018-11-23T06:30:04Z")

</div>

I've tried a bunch of different ways without luck here...  
I want a UI slider (0-100) to be able to vary the brightness of all of the pixels in a ring. I am utterly stumped on how to set msg.brightness. I have no trouble getting (for example) the #RRGGBB value from [io.eclipse.org](http://io.eclipse.org) Cheerlights feed, manipulating it in a function node and fading from one tweeted color to the next using flow context variables (learning by doing). But connecting the output of the slider to the msg.brightness eludes me. Does it set all the pixels at once or is it set once for each pixel?  
There is only one post here that mentions msg.brightness and I'm afraid it doesn't help. Can someone point me in the right direction?  
Thanks.  
--Jeff

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [23 November 2018 07:17 UTC](https://discourse.nodered.org/t/neopixels-how-to-set-msg-brightness/5132/2 "2018-11-23T07:17:28Z")

</div>

I added the brightness function to the node so I may be able to help..... 🙂

msg.brightness sets brightness of all the LEDs

I recommend disabling gamma correction in the node config when using it as low values of brightness will not light up the LEDs

This should show it in action

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4beae813feea9e431de3aeab0f7e652e65659a02.png)

```auto
[{"id":"705d63fe.01c29c","type":"inject","z":"ebdcdbcd.531b48","name":"","topic":"","payload":"red","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":870,"y":440,"wires":[["35d4d55f.0dd83a"]]},{"id":"3154e0ad.cfa47","type":"inject","z":"ebdcdbcd.531b48","name":"","topic":"","payload":"blue","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":870,"y":380,"wires":[["35d4d55f.0dd83a"]]},{"id":"35d4d55f.0dd83a","type":"rpi-neopixels","z":"ebdcdbcd.531b48","name":"","pixels":"21","bgnd":"","fgnd":"","wipe":"3","mode":"pixels","rgb":"rgb","brightness":"5","gamma":false,"x":1150,"y":320,"wires":[]},{"id":"2f20a909.38cb26","type":"inject","z":"ebdcdbcd.531b48","name":"","topic":"","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":260,"wires":[["f3c80bb3.b56f48"]]},{"id":"719f7b9f.7c8d44","type":"inject","z":"ebdcdbcd.531b48","name":"","topic":"","payload":"50","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":360,"wires":[["f3c80bb3.b56f48"]]},{"id":"48d977ad.d015e8","type":"inject","z":"ebdcdbcd.531b48","name":"","topic":"","payload":"100","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":420,"wires":[["f3c80bb3.b56f48"]]},{"id":"f17fef50.c924e","type":"inject","z":"ebdcdbcd.531b48","name":"","topic":"","payload":"10","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":300,"wires":[["f3c80bb3.b56f48"]]},{"id":"f3c80bb3.b56f48","type":"change","z":"ebdcdbcd.531b48","name":"","rules":[{"t":"set","p":"brightness","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":320,"wires":[["35d4d55f.0dd83a"]]}]

```

Simon

---

<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:** [23 November 2018 07:18 UTC](https://discourse.nodered.org/t/neopixels-how-to-set-msg-brightness/5132/3 "2018-11-23T07:18:12Z")

</div>

Not sure exactly what problem you are having. Do you mean you don't know how to put the slider value into msg.brightness? If so then use a Change node set to Move msg.payload To msg.brightness.

---

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [23 November 2018 17:44 UTC](https://discourse.nodered.org/t/neopixels-how-to-set-msg-brightness/5132/4 "2018-11-23T17:44:59Z")

</div>

Putting the slide value into msg.brightness is not the problem, it's that msg.brightness was not doing what I expected it to (change the brightness).

However, after trying Simon's example and having it not work, I checked my Neopixel node version and discovered I was still at 0.16 and not at 0.22. Once updated, everything worked as intended, including the slider. Which, as it turns out, is not really a good way to set the brightness of Nepixels.

@cymplecy thanks again for the (working) example.

Crisis averted.
