I want to make analog toggle switch function digitally


I want to make analog toggle switch function digitally.

But I don't know because it hasn't been long since I started learning how to play Nodered.

I hope the masters will help me.

Toggle switch

  1. If you click middle, pin 38 and pin 40 are turned off.

  2. Click the first button to turn on pin 38 and turn off pin 40.

  3. Click the third button to turn off pin 38 and turn on button 40.

[{"id":"dc376b4c.96c0b8","type":"function","z":"c81baa84.3ded38","name":"GPIO Control","func":"if (msg.topic==='lock' && msg.payload==1) {\n    msg.pin = 38;\n    msg.payload = 1;\n    msg.topic=\"lock\"\n}\n\nif (msg.topic==='lock' && !msg.payload) {\n    msg.pin = 40;\n    msg.payload = 0;\n    msg.topic=\"lock\"\n  \n}\n\nif (msg.topic==='lock2' && msg.payload==1) {\n    msg.pin = 40;\n    msg.payload = 1;\n    msg.topic=\"lock2\"\n}\n\nif (msg.topic==='lock2' && !msg.payload) {\n    msg.pin = 38;\n    msg.payload = 0;\n    msg.topic=\"lock2\"\n  \n}\nnode.send(msg);\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":680,"y":320,"wires":[["49460cff.3da144"]]}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.