Would like to hook up a keypad to the Pi using the input pins and not USB or serial (which have examples in this forum). I have the keypad hooked up and can see the key presses but I am having the following issues.
I don't seem to be able to detect when a key is pressed so that my code could run. Even if I detect the key press my code doesn't seem to work.
I have a flow with inject nodes and I can use those nodes to detect what key is pressed by turning on and off different pins.
The flow is below and if you crack open the function node there are several sections commented out that I have tried that don't work. I suppose this boils down to two issues.
- Detect a keypress - pin changing states to detect when to run code.
- How to turn off and on (or take pin high and low) to detect which key was pressed.
I have to cycle through four pins to be able to detect which key was pressed.
Any and all thoughts would be appreciated, welcomed, applauded and I would be grateful.
Thanks
[{"id":"3dc9a7ec.2c1d58","type":"tab","label":"Keypad","disabled":false,"info":""},{"id":"5b557bd6.de3c9c","type":"rpi-gpio in","z":"3dc9a7ec.2c1d58","name":"GPIO 20-38","pin":"38","intype":"tri","debounce":"25","read":true,"x":170,"y":440,"wires":[["1889ba06.14dc1e","26fb9ad3.dce726"]]},{"id":"ca8d8dc.bffc8f","type":"rpi-gpio in","z":"3dc9a7ec.2c1d58","name":"GPIO 21 - 40","pin":"40","intype":"tri","debounce":"25","read":true,"x":170,"y":380,"wires":[["d952b03f.8f9a3","50591fda.001ac"]]},{"id":"9b4457d4.4a69a8","type":"rpi-gpio in","z":"3dc9a7ec.2c1d58","name":"GPIO 12-32","pin":"32","intype":"tri","debounce":"25","read":true,"x":170,"y":500,"wires":[["5d430998.c72a3","ffcd8607.61938"]]},{"id":"d952b03f.8f9a3","type":"function","z":"3dc9a7ec.2c1d58","name":"21","func":"\n\n\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":380,"wires":[["d02dff4d.314088"]]},{"id":"1889ba06.14dc1e","type":"function","z":"3dc9a7ec.2c1d58","name":"20","func":"\n\n\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":440,"wires":[["d02dff4d.314088"]]},{"id":"5d430998.c72a3","type":"function","z":"3dc9a7ec.2c1d58","name":"16","func":"\n\n\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":500,"wires":[["d02dff4d.314088"]]},{"id":"27853807.02ab28","type":"function","z":"3dc9a7ec.2c1d58","name":"14","func":"\n\n\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":100,"wires":[[]]},{"id":"9e1581ee.c03708","type":"function","z":"3dc9a7ec.2c1d58","name":"15","func":"\n\n\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":160,"wires":[[]]},{"id":"73c431f9.4add9","type":"function","z":"3dc9a7ec.2c1d58","name":"18","func":"\n\n\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":220,"wires":[[]]},{"id":"bbe16b99.3e34","type":"function","z":"3dc9a7ec.2c1d58","name":"23","func":"\n\n\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":280,"wires":[[]]},{"id":"2cdb70f9.c747c","type":"rpi-gpio out","z":"3dc9a7ec.2c1d58","name":"GPIO 14-8","pin":"8","set":true,"level":"1","freq":"","out":"out","x":1090,"y":340,"wires":[]},{"id":"54c21e00.22f534","type":"rpi-gpio out","z":"3dc9a7ec.2c1d58","name":"GPIO 15-10","pin":"10","set":true,"level":"1","freq":"","out":"out","x":1090,"y":400,"wires":[]},{"id":"aab31bc4.57f04","type":"rpi-gpio out","z":"3dc9a7ec.2c1d58","name":"GPIO 18-12","pin":"12","set":true,"level":"1","freq":"","out":"out","x":1090,"y":460,"wires":[]},{"id":"53059eff.01c9d","type":"rpi-gpio out","z":"3dc9a7ec.2c1d58","name":"GPIO 23-16","pin":"16","set":true,"level":"1","freq":"","out":"out","x":1090,"y":520,"wires":[]},{"id":"878c9d6.e5958e","type":"inject","z":"3dc9a7ec.2c1d58","name":"0","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":810,"y":280,"wires":[["2cdb70f9.c747c"]]},{"id":"3507a50f.c9672a","type":"inject","z":"3dc9a7ec.2c1d58","name":"1","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":810,"y":360,"wires":[["54c21e00.22f534"]]},{"id":"155fe75e.c964f9","type":"inject","z":"3dc9a7ec.2c1d58","name":"0","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":810,"y":400,"wires":[["54c21e00.22f534"]]},{"id":"6a83d1f5.58f9a8","type":"inject","z":"3dc9a7ec.2c1d58","name":"1","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":810,"y":460,"wires":[["aab31bc4.57f04"]]},{"id":"a2909f26.c4a908","type":"inject","z":"3dc9a7ec.2c1d58","name":"1","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":810,"y":240,"wires":[["2cdb70f9.c747c"]]},{"id":"437cd9d9.a6fb28","type":"inject","z":"3dc9a7ec.2c1d58","name":"0","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":810,"y":500,"wires":[["aab31bc4.57f04"]]},{"id":"16fd8e79.4ae6e2","type":"inject","z":"3dc9a7ec.2c1d58","name":"1","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":810,"y":560,"wires":[["53059eff.01c9d"]]},{"id":"abb4e0a9.7d40f","type":"inject","z":"3dc9a7ec.2c1d58","name":"0","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":810,"y":600,"wires":[["53059eff.01c9d"]]},{"id":"d02dff4d.314088","type":"function","z":"3dc9a7ec.2c1d58","name":"Logic Node 1","func":"let z = msg.payload;\nlet y = msg.topic;\n\nvar i;\n\n/*\nfor (i = 0; i < 5; i++) {\n msg1 = {payload: 1};\n msg2 = {payload: 1};\n msg3 = {payload: 1};\n msg4 = {payload: 1};\n node.send([msg1,msg2,msg3,msg4]);\n} \n*/\n//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nmsg1 = {payload: 0};\nmsg2 = {payload: 1};\nmsg3 = {payload: 1};\nmsg4 = {payload: 1};\nnode.send([msg1,msg2,msg3,msg4]);\n\nif (msg.payload === 0){\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.topic});\n}\n//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nmsg1 = {payload: 1};\nmsg2 = {payload: 0};\nmsg3 = {payload: 1};\nmsg4 = {payload: 1};\nnode.send([msg1,msg2,msg3,msg4]);\n\nif (msg.payload === 0){\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.topic});\n}\n//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nmsg1 = {payload: 1};\nmsg2 = {payload: 1};\nmsg3 = {payload: 0};\nmsg4 = {payload: 1};\nnode.send([msg1,msg2,msg3,msg4]);\n\nif (msg.payload === 0){\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.topic});\n}\n//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nmsg1 = {payload: 1};\nmsg2 = {payload: 1};\nmsg3 = {payload: 1};\nmsg4 = {payload: 0};\nnode.send([msg1,msg2,msg3,msg4]);\n\nif (msg.payload === 0){\nnode.status({fill:\"blue\",shape:\"dot\",text:msg.topic});\n}\n//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n\n\n\n\n\n//node.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn [null,null,null,null];","outputs":4,"noerr":0,"x":590,"y":440,"wires":[["2cdb70f9.c747c"],["54c21e00.22f534"],["aab31bc4.57f04"],["53059eff.01c9d"]]},{"id":"50591fda.001ac","type":"debug","z":"3dc9a7ec.2c1d58","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":380,"y":320,"wires":[]},{"id":"26fb9ad3.dce726","type":"debug","z":"3dc9a7ec.2c1d58","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":370,"y":560,"wires":[]},{"id":"ffcd8607.61938","type":"debug","z":"3dc9a7ec.2c1d58","name":"3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":370,"y":620,"wires":[]},{"id":"7346ab4d.c0e00c","type":"inject","z":"3dc9a7ec.2c1d58","name":"","repeat":".1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":450,"y":280,"wires":[[]]}]