# Help with Formatting payload

**URL:** <https://discourse.nodered.org/t/help-with-formatting-payload/14920>\
**Category:** General\
**Created:** [29 August 2019 16:32 UTC](https://discourse.nodered.org/t/help-with-formatting-payload/14920 "2019-08-29T16:32:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exit2Studios](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/exit2studios/32/10998_2.png) [@Exit2Studios](https://discourse.nodered.org/u/Exit2Studios)\
**Post date:** [29 August 2019 16:32 UTC](https://discourse.nodered.org/t/help-with-formatting-payload/14920/1 "2019-08-29T16:32:20Z")

</div>

I'm trying to use the following flow to control some relays on an Arduino Nano. I sort of understand how the function node is working (I didn't write it), but I'm at a bit of a loss when it comes to bitSet and bitClear and buffers, etc.

 ![23%20AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/599a6c9ba0566d599d92cabe4ab61dc13a40cb95.png)  
 ![05%20AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f8d42cfe98b73206f0232f64272a218b0dcc7bbe.png)  
I'm able to inject into the hard coded function nodes and the relay turns on and off as expected. However, when I try to pass a variable based on which relay, I'm not able to turn it on, getting a buffer[2] payload instead of the expected buffer[1], but the off functionality works fine.

Flow:  
`[{"id":"b88301ba.690d18","type":"debug","z":"afead276.d8b918","name":"DEBUG","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":110,"wires":[]}]`

The end goal is to have input\_booleans from Home Assistant controlling the various relays, so if anyone has any suggestions on how to streamline this if I'm going down the wrong path, please let me know.

 ![27%20AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0152d1ac5a71b11498d8653cc6d6faf7e507a36c.png)  
Thank you!
