I'd like to ask you to make a toggle stitch


Click the button like a toggle switch to turn the 38 PIN on and the 40th pin off.

Click once again to turn off pin 38 and turn on pin 40.

In the middle, it turns 38 or 40 pins off.

[{"id":"12c046b3.627009","type":"function","z":"a1b61117.83745","name":"","func":"msg.payload =!msg.payload; \nif (msg.payload===false) {\n msg.payload = 0;\n}\n\n\nif (msg.payload===true) {\n msg.payload = 1;\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":360,"wires":[["6a60d6c.9960d28","602ff32e.bb184c","b5bc6a48.7a2458"]]},{"id":"6a60d6c.9960d28","type":"ui_template","z":"a1b61117.83745","group":"6251533e.19840c","name":"OPEN-CLOSED SIGN","order":0,"width":"6","height":"2","format":"<md-button class="vibrate filled touched bigfont rounded" style="background-color:#333333" ng-click="send({payload: msg.payload })"> \n\n\n<svg width="260px" height="90px" version="1.1" viewBox="0 0 800 200">\n <g id="Button_Long">\n \n <rect fill="#333333" width="800" height="200"/>\n <g ng-style="{fill: (msg.payload || 0) ? 'lime' : 'red'}">\n <rect width="800" height="200" rx="80" ry="80"/>\n \n \n <rect fill="#333333" x="11" y="10" width="778" height="180" rx="90" ry="90"/>\n <g ng-style="{fill: (msg.payload || 0) ? 'lime' : 'red'}">\n \n <text x="400" y="125" style="text-anchor:middle" font-weight="bold" font-size="80" font-family="Arial">{{(msg.payload||0)? " 가동 " : "끄기"}} \n \n \n\n\n\n\n","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":530,"y":480,"wires":[["12c046b3.627009","f18421cb.d33c2"]]},{"id":"f18421cb.d33c2","type":"debug","z":"a1b61117.83745","name":"","active":true,"console":"false","complete":"false","x":780,"y":480,"wires":},{"id":"602ff32e.bb184c","type":"rpi-gpio out","z":"a1b61117.83745","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":940,"y":400,"wires":},{"id":"b5bc6a48.7a2458","type":"rpi-gpio out","z":"a1b61117.83745","name":"","pin":"38","set":"","level":"0","freq":"","out":"out","x":940,"y":300,"wires":},{"id":"6251533e.19840c","type":"ui_group","z":"","name":"Control Panel","tab":"31742840.f5b938","order":2,"disp":true,"width":"8"},{"id":"31742840.f5b938","type":"ui_tab","z":"","name":"Button Panel","icon":"dashboard"}]

When posting flows (or code or logs) please use the </> button at the top of the forum entry window and paste the flow in. That stops the forum messing with the text.

For a toggle switch you can use a ui_switch node. Set it to output 1 and 0 and feed that to one of the pins. Also feed the switch into a Range node configured to scale the input range 0/1 to the output range 1/0, then feed that to the other output.

1 Like