Combining change and switch nodes to make logic gates

I've seen a couple of enquiries recently about boolean logic operations and I wondered if they could be done with no code and just the core nodes.

Edit - sorry, wrong screen capture.

[{"id":"9372feccca70ce91","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"426989f0aa2baf1c","type":"group","z":"9372feccca70ce91","name":"AND / NAND","style":{"label":true},"nodes":["1d19ebdbeae23232","c42c81415b813df4","ae8e66805180fa38","8bb8730f87c6f28d","e8e9095ad0f5f89e","7a9624c0fd0d1df1"],"x":294,"y":39,"w":512,"h":182},{"id":"ab0ae8e987862dcf","type":"group","z":"9372feccca70ce91","name":"OR / NOR","style":{"label":true},"nodes":["6fa2afc7c10f8c80","d0693d383dfc4d70","533e6f6ef8b0e2cf","2c0a37a139db2e67","df36f62f924d3140","02c8b90e74cbc498"],"x":294,"y":239,"w":512,"h":182},{"id":"64f83db3dc23ccf9","type":"group","z":"9372feccca70ce91","name":"XOR / XNOR","style":{"label":true},"nodes":["0837287a2f3d7774","0ded0f5f9ad43f76","fb6bdd71b782a52a","a15820faed71189e","e8e4e562fe7d1d70","dd223c5e7da53fa9"],"x":294,"y":439,"w":512,"h":182},{"id":"42ec1989faa796d0","type":"group","z":"9372feccca70ce91","name":"NAND","style":{"label":true},"nodes":["a9b7524e7941e9db","5d10fba115c4027a","0fcd476b67a5ab7a","1ad7fd25c897d9f2","6bb69309997668f7"],"x":294,"y":799,"w":512,"h":122},{"id":"4a85c9e0beaa21ee","type":"group","z":"9372feccca70ce91","name":"NAND","style":{"label":true},"nodes":["4101094a60c95e4b","7b417dba34f17dcd","70093fb1a7d6fb85","4682b44daf4d22be","9276d416eae9be4d"],"x":294,"y":939,"w":512,"h":122},{"id":"5ba4b3220ea1be55","type":"junction","z":"9372feccca70ce91","x":260,"y":300,"wires":[["1d19ebdbeae23232","6fa2afc7c10f8c80","0837287a2f3d7774","075923e2b0610a53"]]},{"id":"650686c876d5bded","type":"junction","z":"9372feccca70ce91","x":860,"y":300,"wires":[["9f39315ff7fb8da4"]]},{"id":"dff5231da6615362","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"1\":true, \"2\":true}","payloadType":"json","x":120,"y":240,"wires":[["5ba4b3220ea1be55"]]},{"id":"5e9e00a6f40dd412","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"1\":true, \"2\":false}","payloadType":"json","x":130,"y":280,"wires":[["5ba4b3220ea1be55"]]},{"id":"a97345035317f0b4","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"1\":false, \"2\":true}","payloadType":"json","x":130,"y":320,"wires":[["5ba4b3220ea1be55"]]},{"id":"6c58fd6a8ca15105","type":"inject","z":"9372feccca70ce91","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"1\":false, \"2\":false}","payloadType":"json","x":130,"y":360,"wires":[["5ba4b3220ea1be55"]]},{"id":"1d19ebdbeae23232","type":"switch","z":"9372feccca70ce91","g":"426989f0aa2baf1c","name":"1 true?","property":"payload.1","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":100,"wires":[["c42c81415b813df4"],["ae8e66805180fa38"]]},{"id":"c42c81415b813df4","type":"switch","z":"9372feccca70ce91","g":"426989f0aa2baf1c","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":80,"wires":[["8bb8730f87c6f28d"],["e8e9095ad0f5f89e"]]},{"id":"ae8e66805180fa38","type":"switch","z":"9372feccca70ce91","g":"426989f0aa2baf1c","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":120,"wires":[["e8e9095ad0f5f89e"],["e8e9095ad0f5f89e"]]},{"id":"8bb8730f87c6f28d","type":"change","z":"9372feccca70ce91","g":"426989f0aa2baf1c","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"AND","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":80,"wires":[["7a9624c0fd0d1df1","650686c876d5bded"]]},{"id":"e8e9095ad0f5f89e","type":"change","z":"9372feccca70ce91","g":"426989f0aa2baf1c","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"AND","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":120,"wires":[["7a9624c0fd0d1df1","650686c876d5bded"]]},{"id":"6fa2afc7c10f8c80","type":"switch","z":"9372feccca70ce91","g":"ab0ae8e987862dcf","name":"1 true?","property":"payload.1","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":300,"wires":[["d0693d383dfc4d70"],["533e6f6ef8b0e2cf"]]},{"id":"d0693d383dfc4d70","type":"switch","z":"9372feccca70ce91","g":"ab0ae8e987862dcf","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":280,"wires":[["2c0a37a139db2e67"],["2c0a37a139db2e67"]]},{"id":"533e6f6ef8b0e2cf","type":"switch","z":"9372feccca70ce91","g":"ab0ae8e987862dcf","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":320,"wires":[["2c0a37a139db2e67"],["df36f62f924d3140"]]},{"id":"2c0a37a139db2e67","type":"change","z":"9372feccca70ce91","g":"ab0ae8e987862dcf","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"OR","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":280,"wires":[["02c8b90e74cbc498","650686c876d5bded"]]},{"id":"df36f62f924d3140","type":"change","z":"9372feccca70ce91","g":"ab0ae8e987862dcf","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"OR","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":320,"wires":[["02c8b90e74cbc498","650686c876d5bded"]]},{"id":"0837287a2f3d7774","type":"switch","z":"9372feccca70ce91","g":"64f83db3dc23ccf9","name":"1 true?","property":"payload.1","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":500,"wires":[["0ded0f5f9ad43f76"],["fb6bdd71b782a52a"]]},{"id":"0ded0f5f9ad43f76","type":"switch","z":"9372feccca70ce91","g":"64f83db3dc23ccf9","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":480,"wires":[["e8e4e562fe7d1d70"],["a15820faed71189e"]]},{"id":"fb6bdd71b782a52a","type":"switch","z":"9372feccca70ce91","g":"64f83db3dc23ccf9","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":520,"wires":[["a15820faed71189e"],["e8e4e562fe7d1d70"]]},{"id":"a15820faed71189e","type":"change","z":"9372feccca70ce91","g":"64f83db3dc23ccf9","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"XOR","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":480,"wires":[["650686c876d5bded","dd223c5e7da53fa9"]]},{"id":"e8e4e562fe7d1d70","type":"change","z":"9372feccca70ce91","g":"64f83db3dc23ccf9","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"XOR","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":520,"wires":[["650686c876d5bded","dd223c5e7da53fa9"]]},{"id":"a9b7524e7941e9db","type":"switch","z":"9372feccca70ce91","g":"42ec1989faa796d0","name":"1 true?","property":"payload.1","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":860,"wires":[["5d10fba115c4027a"],["0fcd476b67a5ab7a"]]},{"id":"5d10fba115c4027a","type":"switch","z":"9372feccca70ce91","g":"42ec1989faa796d0","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":840,"wires":[["6bb69309997668f7"],["1ad7fd25c897d9f2"]]},{"id":"0fcd476b67a5ab7a","type":"switch","z":"9372feccca70ce91","g":"42ec1989faa796d0","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":880,"wires":[["1ad7fd25c897d9f2"],["1ad7fd25c897d9f2"]]},{"id":"1ad7fd25c897d9f2","type":"change","z":"9372feccca70ce91","g":"42ec1989faa796d0","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"NAND","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":880,"wires":[[]]},{"id":"6bb69309997668f7","type":"change","z":"9372feccca70ce91","g":"42ec1989faa796d0","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"NAND","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":840,"wires":[[]]},{"id":"4101094a60c95e4b","type":"switch","z":"9372feccca70ce91","g":"4a85c9e0beaa21ee","name":"1 true?","property":"payload.1","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":1000,"wires":[["7b417dba34f17dcd"],["70093fb1a7d6fb85"]]},{"id":"7b417dba34f17dcd","type":"switch","z":"9372feccca70ce91","g":"4a85c9e0beaa21ee","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":980,"wires":[["9276d416eae9be4d"],["4682b44daf4d22be"]]},{"id":"70093fb1a7d6fb85","type":"switch","z":"9372feccca70ce91","g":"4a85c9e0beaa21ee","name":"2 true?","property":"payload.2","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":540,"y":1020,"wires":[["4682b44daf4d22be"],["4682b44daf4d22be"]]},{"id":"4682b44daf4d22be","type":"change","z":"9372feccca70ce91","g":"4a85c9e0beaa21ee","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"NAND","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":1020,"wires":[[]]},{"id":"9276d416eae9be4d","type":"change","z":"9372feccca70ce91","g":"4a85c9e0beaa21ee","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"NAND","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":980,"wires":[[]]},{"id":"7a9624c0fd0d1df1","type":"change","z":"9372feccca70ce91","g":"426989f0aa2baf1c","name":"swap true/false","rules":[{"t":"set","p":"topic","pt":"msg","to":"NAND","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"temporary","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"temporary","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":180,"wires":[["650686c876d5bded"]]},{"id":"02c8b90e74cbc498","type":"change","z":"9372feccca70ce91","g":"ab0ae8e987862dcf","name":"swap true/false","rules":[{"t":"set","p":"topic","pt":"msg","to":"NOR","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"temporary","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"temporary","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":380,"wires":[["650686c876d5bded"]]},{"id":"9f39315ff7fb8da4","type":"join","z":"9372feccca70ce91","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":930,"y":300,"wires":[["05a06145966345b4"]]},{"id":"6a478126074489ad","type":"debug","z":"9372feccca70ce91","name":"OUTPUT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":380,"wires":[]},{"id":"dd223c5e7da53fa9","type":"change","z":"9372feccca70ce91","g":"64f83db3dc23ccf9","name":"swap true/false","rules":[{"t":"set","p":"topic","pt":"msg","to":"XNOR","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"temporary","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"temporary","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":580,"wires":[["650686c876d5bded"]]},{"id":"05a06145966345b4","type":"change","z":"9372feccca70ce91","name":"del topic","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":340,"wires":[["6a478126074489ad"]]},{"id":"075923e2b0610a53","type":"debug","z":"9372feccca70ce91","name":"INPUT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":170,"y":580,"wires":[]}]

Now I have a NAND gate, I thought "What's to stop me coding a Raspberry Pi Zero emulator in Node-red?"
Probably it would be quite slow since it has to run in Node-red and on a Raspberry Pi Zero.
It turns out that A 512MB SDRAM device will have ~4 billion transistors on it. so it'll take me a while to wire them all together.

4 Likes